ScrollView nested listview causes a slide show to not complete the problem

Source: Internet
Author: User


This method is called after the ListView is initialized Setadapter

/** *  recalculates the height of the ListView, resolves ScrollView and ListView Two view have scrolling effect, conflicts when nested use problem  *  @param   Listview */public void setlistviewheight (Listview listview)  {  //  Get the adapter      listadapter listadapter =  for the ListView Listview.getadapter ();      if  (listadapter == null)  {           return;      }           int totalHeight = 0;       for  (Int i = 0, len = listadapter.getcount (); i <  len; i++)  { // listAdapter.getCount              () returns the number of data items           View  Listitem = listadapter.getview (i,&Nbsp;null, listview);           listitem.measure (0,  0); //  Calculate the height of the child view             Totalheight += listitem.getmeasuredheight (); //  statistics total height of all children        }               Viewgroup.layoutparams params = listview.getlayoutparams ();           params.height = totalHeight +  (Listview.getdividerheight ()  *   (Listadapter.getcoun    t ()  - 1));               listview.setlayoutparams (params);       }



ScrollView nested listview with LinearLayout Wrap, if there are other controls also to be wrapped up with linearlayout

This means that multiple linearlayout can be nested under ScrollView and can be slid


In addition, in the quoted R.layout.item must be used linearlayout can not use a similar relativelayout method, because the method will not be re-measure.















This article is from the "climb over the mountains to see the Sea" blog, please be sure to keep this source http://670176656.blog.51cto.com/4500575/1762065

ScrollView nested listview causes a slide show to not complete the 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.