scrollview的原理就是调用srcollto方法来实现内容的滑动,但是超出屏幕的不能显示完全,原来是它重新测量的子View,将它的height设置为,MeasureSpec.UNSPECIFIED,这个模式和At_most,exactly不一样,它不规定子View的测量,子View的测量交给他自己。
@Override
protected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) {
ViewGroup.LayoutParams lp = child.getLayoutParams();
int childHeightMeasureSpec;
childHeightMeasureSpec = MeasureSpec.makeMeasureSpec( MeasureSpec.getSize(parentHeightMeasureSpec), MeasureSpec.UNSPECIFIED);
child.measure(parentWidthMeasureSpec, childHeightMeasureSpec);
}
这样滑动就能显示整个内容区域了