Fill_parent not working for RelativeLayout in ScrollView

I have a RelativeLayout in a ScrollView on which I set fill_parent. However, it is filled only horizontally, not vertically. I want to add more content to the RelativeLayout, but first I need to find out why the RelativeLayout will not fill the height of the ScrollView.

Thanks for any help.

<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>
+4
source share
2 answers

Add

android:fillViewPort="true"

c ScrollView.

fill_parentor the match_parentheight inside a ScrollViewdoes not really make sense, and it is ignored - otherwise scrolling is not required. fillViewPort="true"Allows you to scroll through the entire vertical space available on the screen.

+10

ScrollView LinearLayout . LinearLayout RelativeLayout. wrap_content.

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/svRecord"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="left"
    android:orientation="vertical"
    android:paddingLeft="12dp"
    android:paddingRight="12dp"
    android:visibility="visible" >
-1

All Articles