@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
Log.e(TAG, "onMeasure");
super.onMeasure(widthMeasureSpec, heightMeasureSpec); final int width = MeasureSpec.getSize(widthMeasureSpec);
final int widthMode = MeasureSpec.getMode(widthMeasureSpec); if (widthMode != MeasureSpec.EXACTLY) {
 throw new IllegalStateException(
 "ScrollLayout only canmCurScreen run at EXACTLY mode!");
} final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
if (heightMode != MeasureSpec.EXACTLY) {
throw new IllegalStateException(
"ScrollLayout only can run at EXACTLY mode!");
} // The children are given the same width and height as the scrollLayout
final int count = getChildCount();
for (int i = 0; i < count; i++) {
getChildAt(i).measure(widthMeasureSpec, heightMeasureSpec);
}
scrollTo(mCurScreen * width, 0);
}
这是这里面的onMeasure方法,它ScrollLayout设置为matchParent,同时也将childView设置为matchParent
但这不是我想要的,我需要childView的宽根据我传的宽度来决定
也就是childView设置为setLayoutParams(自定义值,MatchParent)我该如何改