Android-布局优化merge, viewStub, include总结
多层布局的嵌套会导致页面加载慢,影响用户的体验,今天我们就来学学如何使用 include,merge及viewStub。 1.include include便于对相同视图内容进行统一的控制管理,提高布局重用性,以标题栏为例,我们先定义一个通用的标题栏,相关代码如下: commont_title <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/ll_commontitle_root" android:layout_width="match_parent" android:layout_height="70dp" android:background="#0951C1"> <TextView android:id="@+id/tv_back_commontitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="3dp" android:drawableLeft="@mipmap/back" android:drawablePadding="3dp" android:gravity="center