Android Development essay ScrollView nested gridview
Last Update:2015-09-14
Source: Internet
Author: User
<span id="Label3"></p><p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; white-space: normal; background-color: rgb(255, 255, 255);"><p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-family: KaiTi_GB2312; font-size: 18px;">In the development process always encountered ScrollView nested gridview, because both of these controls with <span style="color: rgb(50, 62, 50); line-height: 21px;">scroll bar, when they encounter together will be problematic, the problem is that the GridView does not scroll, and only display two lines, for this look at the official document, Google answer scrolling there is no need to add scrolling And does not conform to the UI DESIGN. finally, I found a solution to the online daniel. </span></span></p></p> <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; white-space: normal; background-color: rgb(255, 255, 255);"><p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-family: KaiTi_GB2312; font-size: 18px;"><span style="color: rgb(50, 62, 50); line-height: 21px;">Probably write a demo test under, or can be nested use, the early GridView performance seems to be reduced. If the load is too much, the UI load becomes very jammed.</span></span></p></p> <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; white-space: normal; background-color: rgb(255, 255, 255);"><p style="color:rgb (51, 51, 51); font-family:arial; font-size:14px; line-height:26px; white-space:normal; Background-color:rgb (255, 255, 255); "><span style="font-family:kaiti_gb2312; font-size:18px;"><span style="color:rgb (a.); line-height:21px;" primary xml layout is: < span> </span> </span></p></p> <pre class="brush:java;toolbar: true; auto-links: false;"><?xml version= "1.0" encoding= "utf-8"? ><scrollview xmlns:android= "http// Schemas.android.com/apk/res/android " android:layout_width=" fill_parent " android:layout_height= "fill_parent" android:scrollbars= "none" > <LinearLayout Android:layout_width= "fill_parent" android:layout_height= "WRAP_ Content " android:background=" #ff00ff " android:orientation= "vertical" > <com.test.mygridview android: Id= "@+id/gridview" android:layout_width = "fill_parent" android:layout_height= "wrap_content" android:background= "#00ffff" android:numcolumns= "5" /> <LinearLayout Android:layout_width= "fill_parent" android:layout_height= "1000dp" android: background= "#ffff00" > </LinearLayout> </LinearLayout></ScrollView></pre> <p><p> <span style="color:rgb (wuyi, wuyi, wuyi); line-height:26px; font-family:kaiti_gb2312; font-size:18px; background-color:r GB (255, 255, 255); "><span style="color:rgb (), line-height:21px; MyGridView inherits the GridView override Onmeasure method, code: </span> </span> <span style= " font-size:18px; font-family:kaiti_gb2312; color:rgb (50, 62, 50); line-height:21px; background-color:rgb (255, 255, 255); "> </span> </span></p></p> <pre class="brush:java;toolbar: true; auto-links: false;">package com.test;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); } //the custom Control just overrides the GridView Onmeasure method so that it does not appear in the scroll bar, scrollview nested listview is the same reason, no longer repeat. @Override &Nbsp; public void onmeasure (INT&NBSP;WIDTHMEASURESPEC,&NBSP;INT&NBSP;HEIGHTMEASURESPEC) { int expandSpec = Measurespec.makemeasurespec ( integer.max_value >> 2, measurespec.at_most); super.onmeasure (widthmeasurespec, expandspec); } }</pre> <p><p><span style="font-size: 18px; font-family: KaiTi_GB2312; color: rgb(50, 62, 50); line-height: 21px; background-color: rgb(255, 255, 255);"></span><span style="color: rgb(51, 51, 51); font-family: KaiTi_GB2312; font-size: 18px; line-height: 26px; background-color: rgb(255, 255, 255);">The gridview, which is rewritten above, can be nested inside the SCROLLVIEW.</span></p></p><p><p>Android Development essay ScrollView nested gridview</p></p></span>