Android scrollview nested Horizontalscrollview slide problem ScrollView contains GridView display problem

Source: Internet
Author: User

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

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.