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);
}
這樣滑動就能顯示整個內容區域了