Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fill_parent doesn't work for RelativeLayout in ScrollView

I have a RelativeLayout in a ScrollView on which I have set to fill_parent. However, it only fills horizontally, not vertically. There is more content I want to put in the RelativeLayout, but first I need to figure out why the RelativeLayout won't fill the height of the ScrollView.

Thanks for any assistance.

<ScrollView
    android:id="@+id/scrollView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/gray"
    android:layout_below="@+id/previewButton"
    android:layout_marginTop="10dp" >

    <RelativeLayout
        android:id="@+id/relativeLayout"
        android:layout_below="@+id/matchingWordsLabel"
        android:background="@color/white"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        >

        <TextView
            android:id="@+id/titleLabel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:text="Title:"
            />

            <EditText
            android:id="@+id/title"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@+id/titleLabel"
            android:layout_alignBaseline="@+id/titleLabel"
            android:ems="10" />
    </RelativeLayout>
</ScrollView>
like image 694
Casey Perkins Avatar asked Jan 10 '23 16:01

Casey Perkins


1 Answers

Add

android:fillViewPort="true"

to the ScrollView.

fill_parent or match_parent height inside a ScrollView doesn't really make sense and it is ignored - otherwise there would be no need for scrolling. fillViewPort="true" makes the scroll view take up all vertical space available on screen.

like image 98
laalto Avatar answered Jan 17 '23 05:01

laalto