實例:html
<LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:orientation="horizontal" android:weightSum="1"> <Button android:layout_width="0dp" android:layout_height="50dp" android:layout_weight="0.5"/> </LinearLayout>
實例實現效果,Button位於屏幕正中心。android
其中LinearLayout中weightSum屬性表示其內部全部的子視圖的weight比例總和爲1。ios
Button的寬度值爲0dp,所以須要根據weightSum屬性決定Button的width。git
Button的layout_weight屬性值決定Button講佔據LinearLayout的屬性。github
使用ViewStub佈局來設置僅須要顯示時的視圖。如數據爲空時的提示佈局。web
inflatedId屬性是調用inflater()或setVisibility()方法,返回的ID是被填充的View的ID。app
繪製佈局由兩個遍歷過程組成:工具
測量過程:由measure(int, int)方法完成,該方法從上到下遍歷視圖樹。在遞歸遍歷中,每一個視圖都會向下層傳遞尺寸和規格。當該方法執行完成後, 每一個視圖都保存了各自的尺寸信息。佈局
佈局過程:layout(int, int, int, int)也是完成憂傷而下遍歷視圖樹,在遍歷過程當中,每一個父視圖經過測量過程的結果定位全部子視圖的位置信息。google
你們開發app時用到的圖片資源儘可能轉換爲webp格式
google推出的webp圖片通過項目驗證,最差狀況均可以減小一半以上大小並保障顯示質量
能夠有效減小圖片資源形成的apk體積過大問題
android4.0+ 原生支持 android4.0如下:https://github.com/alexey-pelykh/webp-android-backport ios:https://github.com/carsonmcdonald/WebP-iOS-example 轉換工具:http://isparta.github.io/ 參考:https://isux.tencent.com/introduction-of-webp.html 官網:https://developers.google.com/speed/webp/