android listview scrollview auto adapter ui

來源:互聯網
上載者:User

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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.