后来在 elong 摇摇订酒店 项目中发现一个BUG。 就是 当 手机的屏幕尺寸比较大的时候。。。底部的“带我去酒店” 和 scrollview 的间距就变得很大, UI 不美观。
后来解决方案是 将 scrollview 的 layout_weight = 100, 在 “带我去酒店” 的下面再添加一个 空的 适配 LinearLayout . 将其layout_weight = 1. layout_height = 1.
适配组建的代码
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_weight="1"
>
</LinearLayout>
总的来说 , 组建是 按照 layout_weight 按照比例来分配大小的。。。,比如
s = 1 a = 1 那么 s 的高度 /a 的高度= 1/1.
s = 2 a = 1 那么 s 的高度 /a 的高度= 2/1.
s = 2 a = 2 那么 s 的高度 /a 的高度= 2/2.
在开发过程中终于又领会到 layout_weight 的含义。。。 假设 ScrollView 为 S 添加到最后适配用的 LinearLayout 为 A。 下面 给出 S 和 A layout_weight 不同的时候的截图。。
X:
S 1 / A 1 s2/a1
s2 / a2 s100/a1