scrollview的原理就是調用srcollto方法來實現(xiàn)內容的滑動拳氢,但是超出屏幕的不能顯示完全募逞,原來是它重新測量的子View,將它的height設置為馋评,MeasureSpec.UNSPECIFIED放接,這個模式和At_most,exactly不一樣栗恩,它不規(guī)定子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);
}
這樣滑動就能顯示整個內容區(qū)域了