tools:layout屬性:
fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item_list"
android:name="com.example.fragmenttwopanel.ItemListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
tools:context=".ItemListActivity"
tools:layout="@android:layout/list_content" />
一開始不明白,後來刪掉這個屬性之後發現會出現一個提示:
pick preview layout from the "Fragment Layout" context menu
原來tools:layout僅僅是告訴編輯器,Fragment在程序預覽的時候該顯示成什麼樣,並不會對apk產生實際作用,是爲開發者設計的。