如何拉伸布局以填满屏幕?

5
我有一个简单的布局,像这样:(用于邮件)
<ScrollView android:layout_height="0dp" android:layout_width="fill_parent" android:layout_weight="1" android:background="@color/red_start">

        <LinearLayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical" android:background="@color/blue_start">

            <TextView style="@style/MyTextViewLabel" android:text="From" android:layout_marginTop="5dp"/>

            <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/shape_white_rounded">
                <TextView style="@style/MyTextViewLabel.Black" android:id="@+id/tv_sender" />
            </LinearLayout>

            <TextView style="@style/MyTextViewLabel" android:text="Subject" android:layout_marginTop="5dp"/>

            <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/shape_white_rounded">
                <TextView style="@style/MyTextViewLabel.Black" android:id="@+id/tv_subject" />
            </LinearLayout>

            <TextView style="@style/MyTextViewLabel" android:text="Body" android:layout_marginTop="5dp"/>

            <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/shape_white_rounded">
                <TextView style="@style/MyTextViewLabel.Black" android:id="@+id/tv_body" />
            </LinearLayout>

        </LinearLayout>

    </ScrollView>

由于某些原因,LinearLayout不能像我期望的那样填充ScrollView。基本上,我想让tv_body填满屏幕,如果有更多文本-它应该是可滚动的。现在它看起来像这样。我添加了颜色来说明ScrollView被拉伸了,但LinearLayout没有...
2个回答

41

我在滚动视图中嵌套了线性布局。但在这种情况下它不起作用 :( - Arvind Bhardwaj
“top” 应该有 height="fill_parent",除此之外,没有理由它不能工作... 如果你仍然有问题,应该在另一个问题中发布你的问题。 - Matthieu
你救了我,伙计 :) - aida

0
如果您将ScrollView中的android:layout_height="0dp"更改为android:layout_height="match_parent"会发生什么?


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接