how to increase layout(linear/relative) layout height dynamically in android? -
i have requirement in app such should increment linear layout height dynamically adding views it. tried set layout height wrap_content not working properly.
the code snippet looks below:
<?xml version="1.0" encoding="utf-8"?> <scrollview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scrollbars="vertical"> <linearlayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <relativelayout android:id="@+id/linearlayout1" android:layout_width="match_parent" android:layout_height="149dp" android:scrollbars="horizontal" > <textview android:id="@+id/textview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignparenttop="true" android:layout_marginleft="29dp" android:layout_margintop="22dp" android:text="symbol" /> <autocompletetextview android:id="@+id/autocompletetextview1" android:layout_width="140dp" android:layout_height="wrap_content" android:layout_alignbaseline="@+id/textview1" android:layout_alignbottom="@+id/textview1" android:textsize="15dp" android:layout_centerhorizontal="true" > <requestfocus /> </autocompletetextview> <spinner android:id="@+id/spinner1" android:layout_width="wrap_content" android:layout_height="40dp" android:layout_alignleft="@+id/autocompletetextview1" android:layout_centervertical="true" android:entries="@array/type_array"/> <textview android:id="@+id/textview01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbaseline="@+id/spinner1" android:layout_alignbottom="@+id/spinner1" android:layout_alignleft="@+id/textview1" android:text="type" /> <spinner android:id="@+id/spinner01" android:layout_width="wrap_content" android:layout_height="40dp" android:layout_alignleft="@+id/spinner1" android:layout_below="@+id/spinner1" android:entries="@array/expdate_array"/> <textview android:id="@+id/textview02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbaseline="@+id/spinner01" android:layout_alignbottom="@+id/spinner01" android:layout_alignleft="@+id/textview01" android:text="expdate" /> </relativelayout> android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <com.codegineer.datagridclasses.datagrid android:id="@+id/datagrid" android:layout_width="fill_parent" android:layout_height="135dp" android:background="#ffffff"/> <linearlayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <com.codegineer.datagridclasses.datagrid android:id="@+id/datagrid1" android:layout_width="fill_parent" android:layout_height="200dp" android:background="#ffffff" /> </linearlayout> </linearlayout> </scrollview>
here dynamically generated views added 2
thanks in advance!!
- try
linearlayout.invalidate()
, check if updates height according content - if want change height manually, use
layout.getlayoutparams().height = 150
or whatever new height want
Comments
Post a Comment