且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

两个GridView控件与Android的一个滚动

更新时间:2023-11-18 08:00:22

您可以设置在 GridView控件固定,并使用滚动型包含它们

you can set the GridView Fixed ,and use ScrollView include them

public class FixedGridView extends GridView {

public FixedGridView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
}

public FixedGridView(Context context, AttributeSet attrs) {
    super(context, attrs);
}

public FixedGridView(Context context) {
    super(context);
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int expandSpec = MeasureSpec.makeMeasureSpec(
            Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
    super.onMeasure(widthMeasureSpec, expandSpec);

}

}