How To Use Android:layout_weight With Listview
I want to set UI based on android:layout_weight.I have following code structure
Solution 1:
You need to alter your xml as below:
//alterboth LinearLayout as
android:layout_weight="25"
android:layout_height="0dp"
//alter ListView as
android:layout_weight="50"
android:layout_height="0dp"
android:isScrollContainer="false"
Solution 2:
<LinearLayoutandroid:layout_width="fill_parent"android:layout_height="0dp"android:layout_weight="25"android:orientation="horizontal" ><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Button1" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Button1" /></LinearLayout><LinearLayoutandroid:layout_width="fill_parent"android:layout_height="0dp"android:layout_weight="25"android:orientation="horizontal" ><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Button1" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Button1" /></LinearLayout><ListViewandroid:id="@+id/relatedContent"android:layout_width="fill_parent"android:layout_height="0dp"android:layout_marginBottom="60dp"android:layout_weight="50"android:cacheColorHint="@android:color/transparent" ></ListView>
Solution 3:
Put your list view
inside a linear layout
and give layout_weight="50"
to the linear layout
.Then make the listview
width and height to fill parent
.
Also give linear_layout layout height="0dp"
Post a Comment for "How To Use Android:layout_weight With Listview"