Adding a footer to scrollview
I have a scrollview containing a bunch of relative layouts which extends be开发者_如何学Goyond the height of screen. How can I add a linearlayout with 2 buttons that "sticks" to the bottom of the screen. Meaning no matter how I scroll my scrollview, my linearlayout will always appear at the bottom of screen.
<RelativeLayout
android:id="@+id/RelativeLayout01"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ScrollView
android:id="@+id/my_scrollview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="72dip"
android:layout_above="@+id/LinearLayout01"
android:scrollbars="horizontal">
</ScrollView>
<LinearLayout
android:id="@+id/LinearLayout01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true">
<Button
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"">
</Button>
<Button
android:id="@+id/Button02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
</Button>
</LinearLayout>
You can realize this with RelativeLayout.
Your ScrollView should be placed above your button bar and below your header (when applicable).
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ScrollView
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_above="@+id/myFooter">
<!-- Your scroll container -->
</ScrollView>
<RelativeLayout android:id="@+id/myFooter"
android:layout_alignParentBottom="true" android:layout_height="wrap_content"
android:layout_width="fill_parent">
<!-- Your buttons -->
</RelativeLayout>
</RelativeLayout>
精彩评论