Подтвердить что ты не робот

Как сделать linearlayout в scrollview для заполнения всей области

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

    <ScrollView
        android:id="@+id/scrollView1"
        android:background="#000000"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <LinearLayout
            android:id="@+id/linear1"
            android:background="#FF0000"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <LinearLayout
                android:background="#00FF00"
                android:id="@+id/linear2"
                android:layout_width="match_parent"
                android:layout_height="200dip"
                android:orientation="vertical" >
            </LinearLayout>

            <LinearLayout
                android:background="#0000FF"
                android:id="@+id/linear3"
                android:layout_width="match_parent"
                android:layout_height="100dip"
                android:orientation="vertical" >
            </LinearLayout>

        </LinearLayout>
    </ScrollView>
</RelativeLayout>

Это мой макет, и я ожидал увидеть красный фон (потому что у linear1 есть красный фон и есть свойства для заполнения родительского элемента), а еще два макета с линейкой1 с зелеными и синими bacgroudns

но то, что я на самом деле вижу, - черная bacground из scrollview, а зеленая и синяя - из linear2 и linear3, но без красного backgrund from linear1

а именно, линейный действует как android: layout_height = "wrap_content" установлен не android: layout_height = "match_parent"

любые идеи?

4b9b3361

Ответ 1

Вам нужно установить fillViewport:

<ScrollView
    android:id="@+id/scrollView1"
    android:background="#000000"
    android:layout_width="match_parent"
    android:fillViewport="true" <!-- here -->
    android:layout_height="match_parent" >

    ...

 </ScrollView>

информация