include的用法:
<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay"> <include layout="@layout/list_map_parkingarea" /> </android.support.design.widget.CoordinatorLayout>
tools的引入:
<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/list_parking_area" android:layout_width="match_parent" android:layout_height="wrap_content" android:scrollbars="vertical" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context=".BaseActivity" tools:showIn="@layout/activity_parking_area_list" />
总结:
用<include>可以在xml中引入其他的文件
在xml中用tools: 在container容器中先引入: xmlns:tools="http://schemas.android.com/tools"
tools:context=".BaseActivity" tools:showIn="@layout/包含它的布局文件。"