实例: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/