Reputation: 6220
I am trying to solve this problem but I didn't found anything that helps me.
I have this layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp">
<LinearLayout
android:id="@+id/list_lv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/profile_layout"
android:layout_marginTop="8dp"
android:background="@drawable/border"
android:orientation="vertical"
android:padding="8dp"
android:weightSum="1">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@id/list_lv"
android:layout_centerHorizontal="true"
android:background="@android:color/darker_gray" />
</RelativeLayout>
In which I want to show a fragment below the listview. In code it is like this (Code for ListActivity
:
getFragmentManager().beginTransaction().add(R.id.container, new BottomMenuFragment()).commit();
// Populate lisview and set adapter
But when I run the app, the fragment is not shown, I think the problem is with the attribute android:layout_height="wrap_content"
of the ListView
list_lv
. But I have not idea of how to solve it. Here is an screenshot with multiple data in the list:
And with few items:
Upvotes: 1
Views: 209
Reputation: 2357
Try this. Sure it will solve your issue:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<FrameLayout
android:id="@+id/list_lv"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:orientation="vertical"
android:padding="8dp"
android:layout_weight="0.5">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</FrameLayout>
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:background="@android:color/darker_gray" /> </LinearLayout>
Vote if it works fine!
Upvotes: 0
Reputation: 175
Put the listview above the framelayout. Remove android:layout_below="@id/list_lv" from FrameLayout and add android:layout_above="@id/container" to LinearLayout. Below is th ecode snippet:
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@android:color/darker_gray" />
<LinearLayout
android:id="@+id/list_lv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/profile_layout"
android:layout_above="@id/container"
android:layout_marginTop="8dp"
android:background="@drawable/border"
android:orientation="vertical"
android:padding="8dp"
android:weightSum="1">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Upvotes: 1
Reputation: 10815
Try with this xml layout basically will help you :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="10"
android:orientation="vertical"
android:layout_margin="8dp">
<LinearLayout
android:id="@+id/list_lv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/profile_layout"
android:layout_marginTop="8dp"
android:background="@drawable/border"
android:orientation="vertical"
android:padding="8dp"
android:layout_weight="8">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<FrameLayout
android:layout_weight="2"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_alignParentBottom="true"
android:layout_below="@id/list_lv"
android:layout_centerHorizontal="true"
android:background="@android:color/darker_gray" />
</LinearLayout>
Upvotes: 1