I have the following setup to get a layout with header and footer. Since the activity is displayed in a dialog, i want to set the height of the top element to “wrap_content”. Regarding to the android docs this not possible as long as you set alignParentBottm=”true” to a child element.
In an other question someone proposed to use a LinearLayout and set the maxHeight programmatically. Are there any other ways to avoid alignParentBottom=”true” ?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/LNL_TOP"
android:layout_width="match_parent"
android:layout_height="60dip"
android:layout_alignParentTop="true">
</LinearLayout>
<LinearLayout
android:id="@+id/LNL_BOTTOM"
android:layout_width="match_parent"
android:layout_height="60dip"
android:layout_alignParentBottom="true">
</LinearLayout>
<LinearLayout
android:id="@+id/LNL_CONTENT"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/LNL_TOP"
android:layout_above="@+id/LNL_BOTTOM">
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</RelativeLayout>
Here is an image of what it currently looks like, I want the layout to wrap the content and avoid the empty space under the list.

Use a vertical LinearLayout instead:
With this, the body will grow with its content until there is no more space. Then it will start to go down behind the footer (although this shouldn’t be a problem as you use a ListView for the contents, so the view will expand to maximum size and then stop, and the scrolling will start to work).