项目中常用到scrollview中包含viewpager与gridview或者listview,就会产生一些问题,如scrollview 中嵌套listview,结果只显示不全,后来发现要固定铲毒,就自定义listview重写onMeasute
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
scrollview中嵌套viewpager不可见,除非固定viewpager高度,这很不实际,解决方法:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/theme_bg"
android:fillViewport="true">
Android:fillViewport="true"
还有就是gridview,listview抢占焦点,导致每次跳的listview或gridview第一个,解决方法:
让其失去焦点 listview.setFocusable(false);