自定义GridView获取数据长度来解决scrollView嵌套GridView数据显示不全问题

packagecom.example.topgridview;importandroid.content.Context;importandroid.util.AttributeSet;importandroid.view.View.MeasureSpec;importandroid.widget.GridView;publicclassMyGridViewextendsGridView{publicMyGridView(Context context, AttributeSet attrs){super(context, attrs); }publicMyGridView(Context context){super(context); }publicMyGridView(Context context, AttributeSet attrs,intdefStyle){super(context, attrs, defStyle); }@OverridepublicvoidonMeasure(intwidthMeasureSpec,intheightMeasureSpec){intexpandSpec = MeasureSpec.makeMeasureSpec( Integer.MAX_VALUE >>2, MeasureSpec.AT_MOST);super.onMeasure(widthMeasureSpec, expandSpec); }}android:id="@+id/grid"android:layout_width="match_parent"android:layout_height="wrap_content"android:gravity="center"android:horizontalSpacing="12dp"android:numColumns="3"android:verticalSpacing="10dp"android:background="#fff"

你可能感兴趣的:(自定义GridView获取数据长度来解决scrollView嵌套GridView数据显示不全问题)