MikeS
MikeS

Reputation: 3921

Android ScrollView XML Layout Size Strangeness

My mind is a bit boggled... in the following XML, I would expect my LinearLayout/TextView to be the same size as my ScrollView. As you can see from my included image, this is not the case.

What is going on here? Why is my LinearLayout not the same size as the ScrollView?

<ScrollView
    android:id="@+id/scrollView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#008B8B" >

    <LinearLayout
        android:id="@+id/contentLayout"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#DC143C" >

        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="hello" />
    </LinearLayout>

</ScrollView>

enter image description here

Upvotes: 0

Views: 81

Answers (1)

Mohsin Naeem
Mohsin Naeem

Reputation: 12642

use

android:fillViewport="true"

in your ScrollView

Upvotes: 1

Related Questions