後來在 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