How do I place widgets above and below a listview with Relative Layout
- by Jay Askren
I have a list view and want to put stuff both above(on the y axis) and below(y axis) it including images, text views, and a row of buttons. Below is a simplified version of what I am creating. Unfortunately the list covers(i.e. above on the z axis) the header so the header text is not visible instead of being underneath (on the y axis)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:id="@+id/footer"
android:text="footer"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
/>
<ListView android:id="@+id/list_view"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_above="@id/footer"
android:background="#ff9999ff"/>
<TextView android:id="@+id/header"
android:text="header"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignParentTop="true"
android:layout_above="@id/list_view"
android:baselineAlignBottom="false"
/>
</RelativeLayout>
Here is the corresponding Activity class:
public class SampleListActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list_activity);
}
}