I have a scrollview containing a bunch of relative layouts which extends beyond 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.
Asked
Active
Viewed 6,471 times
5
-
Question has been answered here. Please check http://stackoverflow.com/a/42864776/2010056 – Amar Jain Mar 17 '17 at 18:32
2 Answers
7
<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>

2red13
- 11,197
- 8
- 40
- 52
-
Yep. its not compilable but its the correct answer. i.e. the idea is correct. Just need to declare the
before – Bkteo Mar 30 '11 at 09:16
5
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>

321X
- 3,153
- 2
- 30
- 42
-
'+1' ya 321x is right if it didnt works then just put myFooter layout abve ur scrollview and try it work ....thanks. – Ganapathy C Mar 29 '11 at 09:40