问题描述
我有一个垂直的,设置高度(300像素)的LinearLayout(LL)与3嵌套LLS。 1和第3的设置与Android:layout_height =WRAP_CONTENT和中间的一个与Android:layout_height =FILL_PARENT。令我失望的是,第3 LL被排挤出具有:第二个灌装父布局右底部。我如何达到预期的效果,因为我想有可能调整外容器的中间部分膨胀和收缩,以适应变化
I have a vertical, set height (300px) LinearLayout (LL) with 3 nested LLs. 1 and 3rd are set with android:layout_height="wrap_content" and the middle one with android:layout_height="fill_parent". To my dismay, 3rd LL gets pushed out with 2nd one filling parent layout right to the bottom. How do I achieve desired effect since I want potentially resize the outside container with the middle portion expanding and contracting to accommodate the change
推荐答案
横空出世(感谢马克·墨菲<一href="https://groups.google.com/group/android-developers/browse_thread/thread/a08e42713ce94f43/e9e31d27e3e31845?lnk=gst&q=droidin#e9e31d27e3e31845">for答案),所有我要买的是设置中间行
Turned out (Thanks Mark Murphy for the answer) that all I was looking for was to set middle row to
layout_height =0px和layout_weight =1
layout_height="0px" and layout_weight="1"
如果,毕竟WRAP_CONTENT和固定大小的项目分配给 沿着轴线(水平或垂直),仍有空间上轴 遗留,的LinearLayout然后分配的剩余空间的那些 部件与指定的权重,按比例的权重。
这篇关于安卓的LinearLayout补这方面的中间人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!