Use of the gridview + ScrollView on the set-top box ., Gridviewscrollview
Recently, I made a gridview on the set-top box,
The focus must be on the item child control, but the focus of the gridview is on the item by default.
android:descendantFocusability="afterDescendants"
<ScrollView android:id="@+id/scroll_content" android:layout_width="1740.0px" android:layout_height="600.0px" android:layout_x="81.0px" android:layout_y="258.0px" > <com.hysmarthotel.view.MyGridView android:id="@+id/lightview" android:layout_width="match_parent" android:layout_height="match_parent" android:descendantFocusability="afterDescendants" android:horizontalSpacing="58dp" android:numColumns="4" android:scrollbars="none" android:stretchMode="columnWidth" android:verticalSpacing="80dp" /> </ScrollView>
Allows the child control of the gridview to get the focus. However, after this attribute is added, the gridview will become unable to scroll. Then I added a ScrollView TO THE gridview,
However, since both of them have a scroll bar, I overwrite a gridview to make it disappear. Finally, the gridview is successfully enabled to keep the child control focused and smooth.
Scroll.
package com.hysmarthotel.view;import android.content.Context;import android.util.AttributeSet;import android.widget.GridView;public class MyGridView extends GridView { public MyGridView(Context context, AttributeSet attrs) { super(context, attrs); } public MyGridView(Context context) { super(context); } public MyGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec( Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); } }
Ps: My layout is absolute, and there is nothing special about the item layout and the adapter code. The CheckBox focus level is very high.