- Fixing content at the bottom of the screen in Android
- <?xml version="1.0" encoding="utf-8"?>
- <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/ScrollView01"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:fillViewport="true" >
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="0dp"
- android:orientation="vertical" >
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_gravity="center_horizontal"
- android:layout_weight="1"
- android:gravity="center_horizontal" >
- <TextView ... />
- ...
- <TextView ... />
- </LinearLayout>
- <Button
- android:id="@+id/ButtonMain"
- android:layout_width="fill_parent"
- android:layout_height="0dp"
- android:layout_gravity="center_horizontal"
- android:layout_marginLeft="5dp"
- android:layout_marginRight="5dp"
- android:layout_weight="1"
- android:text="@string/button_text"
- android:textSize="30px"
- android:textStyle="bold"
- android:width="200px" />
- </LinearLayout>
- </ScrollView>
- android:layout_alignParentBottom="true"
- <?xml version="1.0" encoding="utf-8"?>
- <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/scroller"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:fillViewport="true" >
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:gravity="center_horizontal"
- android:orientation="vertical" >
- <TextView
- android:id="@+id/txt1"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:text="Hello"
- android:textSize="25sp" />
- <TextView
- android:id="@+id/txt2"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:text="Hello2"
- android:textSize="25sp" />
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:gravity="bottom|center"
- android:orientation="horizontal" >
- <Button
- android:id="@+id/ButtonMain"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="5dp"
- android:layout_marginRight="5dp"
- android:text="click me"
- android:textSize="30px"
- android:textStyle="bold" />
- </LinearLayout>
- </LinearLayout>
- </ScrollView>
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
- <ScrollView
- android:id="@+id/ScrollView01"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"
- android:fillViewport="true" >
- <!-- You can remove one of these two LinearLayouts, since they just nest each other. Which one you want to remove is up to you. -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal"
- android:gravity="center_horizontal" >
- <TextView ... />
- ...
- <TextView ... />
- </LinearLayout>
- </LinearLayout>
- </ScrollView>
- <Button
- android:id="@+id/ButtonMain"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="5dp"
- android:layout_marginRight="5dp"
- android:text="@string/button_text"
- android:textSize="30px"
- android:textStyle="bold"
- android:width="200px" />
- </LinearLayout>