I am trying to get a quite simple layout in Android, but I just can’t get it to work. All I want is a header (by include an XML file), followed by a ScrollView to show a large body of text, and two buttons in the bottom, that should always be visible.
I have fiddled with LinearLayouts and RelativeLayouts, but somehow, I can’t get it to work. What I have until now is this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include layout="@layout/header" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ScrollView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/svDisclaimer"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/tvDisclaimer">
</TextView>
</ScrollView>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/svDisclaimer"
>
.. [ snip ] ..
</LinearLayout>
</RelativeLayout>
</LinearLayout>
( .. [snip] .. is where my buttons are)
The header is there, the scrollview pops up, but the buttons are nowhere to be seen.
Your ScrollView’s height is set to
fill_parentwhich pushes everything below the ScrollView off the bottom of the screen. You will never see what you cannot scroll to… try this pattern instead:You can probably remove the LinearLayout by using the RelativeLayout position tags as well. (
android:below,android:toRightOf, etc)Try using this configuration from my comment: