在布局优化中,Androi的官方提到了这三种布局<include />、<merge />、<ViewStub />,并介绍了这三种布局各有的优势,下面也是简单说一下他们的优势,以及怎么使用,记下来权当做笔记。
1、布局重用<include />
<include />标签能够重用布局文件,简单的使用如下:
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width=”match_parent”
- android:layout_height=”match_parent”
- android:background="@color/app_bg"
- android:gravity="center_horizontal">
-
- <include layout="@layout/titlebar"/>
-
-