I need to display an ListView between a LinearLayout and a Relative Layout. I want that the height of the ListView to be display according to the screen dimensions. For that, I put layout_height=”wrap_content”, and I user layout_above and layout_belowm but this returns this :”Circular dependence cannot exist in RelativeLayout”.
Here is my layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/firstLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/roadmap_linearlayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center"
android:orientation="horizontal" >
........
</LinearLayout>
<ListView
android:id="@+id/listvisit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/roadmap_linearlayout"
android:layout_above="@+id/relativelayout_listpostovisit"
android:layout_marginTop="10dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:cacheColorHint="@android:color/transparent"
android:divider="@drawable/listview_divider"
android:dividerHeight="2dp"
android:scrollbars="vertical" />
<RelativeLayout
android:id="@+id/relativelayout_listpostovisit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/listvisit"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#FFFFFF"
android:orientation="vertical"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true">
.........
</RelativeLayout>
</RelativeLayout>
Any idea how to solve this ?
Thanks in advance.
I am going to translate this as meaning “I want the
ListViewto fill the available screen space”.You cannot reliably use
android:layout_height="wrap_content"on aListView.That is because your outer
RelativeLayoutconfiguration hasrelativelayout_listpostovisitdepend upon the position oflistvisitand the position oflistvisitdepend upon the position ofrelativelayout_listpostovisit. That cannot work.Either:
Change
relativelayout_listpostovisit, removingandroid:layout_below="@id/listvisit"and addingandroid:layout_alignParentBottom="true", orSwitch the outer container to be a
LinearLayoutrather than aRelativeLayoutand switch to usingandroid:layout_weightto allocate extra space to theListView.