android - How to assign wrap_content as height to dynamically loaded gridview -


i loading gridview dynamically buttons. using scrollview, if assign wrap_content height gridview buttons not displayed. dont want assign static height gridview. code using:

<scrollview                  xmlns:android="http://schemas.android.com/apk/res/android"               android:layout_width="fill_parent"               android:layout_height="fill_parent" >                <linearlayout                   android:layout_width="fill_parent"                   android:layout_height="fill_parent"                   android:orientation="vertical"                   android:paddingleft="5dip"                   android:paddingright="5dip" >                    <gridview                       android:id="@+id/gridviewtable"                       android:layout_width="fill_parent"                       android:layout_height=wrap_content"                       android:horizontalspacing="10dp"                       android:numcolumns="4"                       android:verticalspacing="10dp" >                   </gridview>                </linearlayout>           </scrollview> 

try

int totalheight = (count / <number of items in row>);      if (count % <number of items in row> != 0) {         totalheight++;     }      viewgroup.layoutparams params = gridview.getlayoutparams();      params.height = <height of row> * totalheight;      gridview.setlayoutparams(params);     gridview.requestlayout(); 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -