user468311
user468311

Reputation:

Scrollview and nested LinearLayouts

Here's my layout file:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/yellow" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <include
            android:id="@+id/header"
            layout="@layout/header" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginTop="10dp"
            android:background="@drawable/green"
            android:orientation="vertical" >

            <TextView/>

            <TextView/>

            <TextView/>

            <TextView/>

        </LinearLayout>
    </LinearLayout>

</ScrollView>

And here's how it looks:

enter image description here

Blue is header, Yellow is ScrollView and Green is LinearLayout which I want to fill the space marked with red arrow.

I use one more LinearLayout which contains the header and green LinearLayout in order to use ScrollView.

Problem: How do I make Green LinearLayout fill the entire space to the bottom?

Upvotes: 0

Views: 1450

Answers (1)

Pedro Loureiro
Pedro Loureiro

Reputation: 11514

On the ScrollView, try to set the fill viewport to true.

You can do it either by xml or code.

http://developer.android.com/reference/android/widget/ScrollView.html#setFillViewport(boolean)

Upvotes: 3

Related Questions