user2426316
user2426316

Reputation: 7331

Is it possible to set a textview at the bottom of a scrollview in Android?

I have got a layout that looks something like this:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<LinearLayout 
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:layout_margin="10dp">

//Some content

</LinearLayout>
</ScrollView>

Now, is it possible to set a textview at the bottom of the scrollview? It should always stay at the bottom of the page.

Thanks!

Upvotes: 2

Views: 1895

Answers (2)

Tarsem Singh
Tarsem Singh

Reputation: 14199

try

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ScrollView
        android:layout_above="@id/textView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:gravity="center"
            android:orientation="vertical" >
         //Some content
        </LinearLayout>
    </ScrollView>

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:text="Your text" />

</RelativeLayout>

Upvotes: 3

MrZander
MrZander

Reputation: 3090

You can put a LinearLayout with a vertical orientation as the root element and have the ScrollView and TextView be children.

<LinearLayout>
    <ScrollView>
    ...
    </ScrollView>
    <TextView ... />
</LinearLayout>

Upvotes: 1

Related Questions