在apkbus上看到的一个问题,之前也遇到过,后来便不了了之。
下面是该问题当时的答案,总觉的有些不太优美。大家有什么好方法么?谢谢。<?xml version="1.0" encoding="utf-8"?>
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffe0e8ec"
android:orientation="vertical" >
android:layout_width="fill_parent"
android:layout_height="20dip" />
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.0" />
android:layout_width="fill_parent"
android:layout_height="20dip" />
---------------------------------更新-------------------------------------
由于我对android:layout_weight属性的不了解导致了这个问题的出现,经过研究发现android:layout_weight是个很有趣的属性,上面的解决方法非常巧妙。
先来看看什么是android:layout_weight:Layout weight is used to determine how Android divides up any left over space after the various widgets get all of the space they want.
上面代码中将中间LinearLayout的android:layout_weight设置为1,也就等于中间的LinearLayout占据了剩下的所有空间,很好了解决的layout中高度的问题。