Fragment 佈局屬性 tools:layout 作用

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產生實際作用,是爲開發者設計的。

發佈了30 篇原創文章 · 獲贊 3 · 訪問量 11萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章