1.ScrollView nested ListView, touch event interception problem.
Reference http://www.cnblogs.com/lqminn/archive/2013/03/02/2940194.html
http://blog.csdn.net/chaihuasong/article/details/17499799
_scrollview.requestdisallowintercepttouchevent (true);
The meaning of this sentence is to tell ScrollView that the rolling events are handed to me for processing. Remember to return it when you're done.
_scrollview.requestdisallowintercepttouchevent (false);
If you do not set it back, ScrollView will not be able to scroll.
2.ScrollView scrolling, is the first entry in the ListView in the display state?
Reference http://stackoverflow.com/questions/4628800/android-how-to-check-if-a-view-inside-of-scrollview-is-visible
BooleanCheckneedrefresh () {Rect scrollbounds=NewRect (); View FirstChild= Listview.getchildat (0); _scrollview.gethitrect (Scrollbounds); if(Firstchild.getlocalvisiblerect (scrollbounds)) {//Any portion of the firstchild, even a-pixel, is within the//Visible Window return true; } Else { //NONE of the firstchild is within the visible window return false; } }
3. The ListView cannot display the full
Reference http://blog.csdn.net/hahashui123/article/details/39177057
http://blog.csdn.net/solomonxiang/article/details/26507145
Public Static voidSetlistviewheight (ListView listview) {Try { intTotalheight = 0; ListAdapter Adapter=Listview.getadapter (); for(inti = 0, Len = Adapter.getcount (); i < Len; i++) {//Listadapter.getcount ()View ListItem = Adapter.getview (i,NULL, ListView); Listitem.setlayoutparams (Newlayoutparams (layoutparams.wrap_content, layoutparams.wrap_content)); Listitem.measure (0, 0); Totalheight+=listitem.getmeasuredheight (); } viewgroup.layoutparams params=Listview.getlayoutparams (); Params.height=Totalheight+ (Listview.getdividerheight () * (Listview.getcount ()-1)); Listview.setlayoutparams (params); } Catch(Exception ex) {ex.printstacktrace (); } }
Incidentally, the GridView
Public Static voidSetgridviewheight (GridView GridView,intNumColumns) { Try{ListAdapter Adapter=Gridview.getadapter (); introw = 3; View ListItem= Adapter.getview (0,NULL, GridView); if(ListItem = =NULL) return; Listitem.setlayoutparams (Newlayoutparams (layoutparams.wrap_content, layoutparams.wrap_content)); Listitem.measure (0, 0); intTotalheight = Listitem.getmeasuredheight () *Row+ (Gridview.getverticalspacing () * (row-1)); Viewgroup.layoutparams params=Gridview.getlayoutparams (); Params.height=Totalheight; Gridview.setlayoutparams (params); } Catch(Exception ex) {ex.printstacktrace (); } }
If the ListView is with Bottomview
Public Static voidSetlistviewheight (ListView listview) {Try { intTotalheight = 0; intBottomheight = 0; ListAdapter DataAdapter=NULL; intTotalItems = 0; ListAdapter Adapter=Listview.getadapter (); if(Adapterinstanceofheaderviewlistadapter) {Headerviewlistadapter Headerviewlistadapter=((Headerviewlistadapter) adapter); DataAdapter=Headerviewlistadapter.getwrappedadapter (); TotalItems=Dataadapter.getcount (); intAllItems =Headerviewlistadapter.getcount (); View Bottomitem= Headerviewlistadapter.getview (allItems-1, NULL, ListView); Bottomitem.measure (0, 0); Bottomheight=bottomitem.getmeasuredheight (); } Else{DataAdapter=adapter; } for(inti = 0, len = totalitems; i < Len; i++) {View ListItem= Dataadapter.getview (I,NULL, ListView); Listitem.setlayoutparams (Newlayoutparams (layoutparams.wrap_content, layoutparams.wrap_content)); Listitem.measure (0, 0); Totalheight+=listitem.getmeasuredheight (); } intListviewcount =Listview.getcount (); intHeight =Totalheight+ (Listview.getdividerheight () * Listviewcount + 1) +Bottomheight; Viewgroup.layoutparams params=Listview.getlayoutparams (); Params.height=height; Listview.setlayoutparams (params); Listview.requestlayout (); } Catch(Exception ex) {ex.printstacktrace (); } }
4. Miscellaneous, custom control implementation ListView
Http://www.cnblogs.com/lesliefang/p/3587154.html
Summary of issues used with Android ScrollView and ListView