Today the project used to ScrollView nested Horizontalscrollview,scrollview contains the GridView, and found several questions very classic, in this record:
Question 1. ScrollView nested Horizontalscrollview jump problem, ScrollView, Horizontalscrollview automatically pull down to the last line;
Set to initial coordinate (0,0) Workaround:
(Timing: The following code is set after the data is parsed and refreshed notifydatasetchanged ())
Scrollview.smoothscrollto (0, 0);
Horizontalscrollview.fullscroll (Scrollview.focus_left);
Attention:
These two lines of code do not achieve the effect (Scrollview.fullscroll (SCROLLVIEW.FOCUS_UP); Horizontalscrollview.fullscroll (Scrollview.focus_left); )
Question 2. ScrollView conflict with GridView, GridView cannot display all data;
GridView If you know the size of a row can be directly given a height, but the general data is not fixed, so just GetView () simple setup to solve the problem:
Collections.sort (ArrayList); custom height data based on analytic data is placed in the collection and sorted in ascending order
linearlayout.layoutparams LP2 = (android.widget.LinearLayout.LayoutParams) gridview.getlayoutparams ();
Lp2.height=arraylist.get (Arraylist.size ()-1);//height take ascending the maximum height of the set is the last one
Gridview.setlayoutparams (LP2);
Android scrollview nested horizontalscrollview slide problem ScrollView contains GridView display problem