I added two ListViews in a layout. I want them to maintain their 'layout_weight's throughout the activity. But when I add items to the second ListView, first one shrinks ignoring the layout_weight assigned. How can I solve this issue?
Here's what I expect :
And here's the code :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content_add_group_members_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:orientation="vertical">
<TextView
android:id="@+id/content_add_group_text_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="First List" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#DDD" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ListView
android:id="@+id/list_added_people"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/added_people_empty_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="List One Empty View"/>
</FrameLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="7"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Second List" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#DDD" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/list_contacts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false" />
<TextView
android:id="@+id/contacts_empty_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="List Two Empty View"/>
<com.github.silvestrpredko.dotprogressbar.DotProgressBar
android:id="@+id/dots"
android:layout_width="wrap_content"
android:layout_height="16dp"
android:layout_gravity="center"
android:visibility="gone" />
</FrameLayout>
</LinearLayout>
</LinearLayout>