The use of GridView and ScrollView on the Android set-top box _android

Source: Internet
Author: User

Recently made a GridView on the set-top box,

The focus needs to be on the child control of item, but the GridView focus defaults on item, by
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 "/>

You can get the focus for the GridView child control. But after adding this attribute, the GridView becomes unable to scroll, and then I add a scrollview to the GridView,

But since all two have scroll bars, I rewrite a gridview to let the scroll bar disappear. Finally succeeded in allowing the GridView to keep the child control focused and to scroll smoothly.

Package Com.hysmarthotel.view;
Import Android.content.Context;
Import Android.util.AttributeSet;
Import Android.widget.GridView;
public class MyGridView extends the GridView {public 
MyGridView (context context, AttributeSet Attrs) { 
super ( context, attrs); 
} 
Public MyGridView { 
super (context); 
} 
Public MyGridView (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 absolutely layout, and there is nothing special about the layout of the item and the adapter code. CheckBox focus level is high.

The above content to introduce the Android development of the set-top box on the GridView and ScrollView of the use of detailed, hope to help everyone!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.