I have a layout and I want the components to fill up the remaining part of the screen (using weights). The Listview works perfectly.
The 2 buttons at the end work the way I intent them to work also, however I get a warning which says “Nested weights are bad for performance”.
I think it’s a problem because I already used a weight parameter for the Listview, because when I remove the listview the warning is gone.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/listMessages_messages"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_marginBottom="5dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:layout_weight="1"
android:background="#000000" >
</ListView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="50"
android:visibility="invisible" />
<Button
android:id="@+id/btnNewConversation_message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="50"
android:onClick="newConversation"
android:text="@string/NewConversation" />
</LinearLayout>
</LinearLayout>
Check this code. Im not getting warning
As you placing both views
1.List View
2.Linear Layout (Two buttons)
you need to give weight property to adjust them properly and for horizontal divison for buttons also give some weight sum property to second linear layout divide it equally using weights. note within second linear layout i used width for buttons to 0px