如何拉伸布局以填充屏幕?
问题描述:
我有简单的布局是这样的:(它是邮件)如何拉伸布局以填充屏幕?
<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不会填满滚动型。基本上,我想让tv_body填充屏幕,如果有更多的文本 - 它应该是可滚动的。现在看起来像这样。我添加颜色以表明滚动型弹力但LinearLayout中不..
答
尝试在你的滚动型加
android:fillViewport="true"
。
结帐这更多的解释:http://www.curious-creature.org/2010/08/15/scrollviews-handy-trick/
答
如果您在滚动型改变android:layout_height="0dp"
到android:layout_height="match_parent"
会发生什么?
+0
没有做出区别 – katit 2011-05-26 02:34:56
很好,谢谢!这工作 – katit 2011-05-26 02:37:35
辉煌,帮助我以及.. – bluszcz 2012-04-29 19:10:48
我已经嵌套滚动视图内的线性布局。它在这种情况下不起作用:( – 2012-07-04 05:42:27