Tools attributes reference 介紹

整理 Tools attributes reference 

官方的文件 連結

可以先了解 developers 文件,接著下面的整理,會比較有感覺.主要是針對 xml 在設計時的額外支援,不會影響到 apk 的大小及 APP 在執行時的效果.

1. tools:text 及 tools:visibility 

新增 TextView,屬性 text = "測試專案", visibility = "gone",所以 UI 畫面上看不到任何東西.


加入 tools:text 及 tools:visibility,效果會覆蓋掉原本 .xml 檔的設定


反過來設定 tools:visibility,visibility 設定成 gone 畫面中的 TextView 會消失

2. tools:itemCount

RecyclerView 沒有做任何設定,預設會顯示 item0 ~ item9


設定 itemCount 為 3 後就只會顯示 3 個 item0 ~ item2

3. tools:listitem

測試在 RecyclerView 中加入自行設計的 Layout,.xml 名稱 stock_list_item.xml

UI 畫面

加入 tools:listitem,這部分沒有加入任何的程式碼,只是靠 .xml 檔的設定

tools:itemCount = 3, tools:listitem 帶入設定的 Layout.

* 備註:如果替換成 ListView,listitem 有效果 itemCount 會失效.


3. tools:listheader 及 tools:footer

( 透過 ListView 測試 )

新增 stocker_list_header UI 畫面


新增 stocker_list_footer UI 畫面


tools:listheader 及 tools:listfooter 加入 .xml 檔,可以直接預覽.

4. 文件提及 Attribute Value


有提供幾個比較常用的參數,可以快速提供使用

@tools:sample/full_names 效果

Resource 資源檔也有提供

@tools:sample/avatars

後記

如果這篇文章對於你有幫助,可以幫忙分享給更多的人.文章內容如果有誤,可以在下方留言告知.本網站主要提供程式相關資訊,可以訂閱獲得最即時的資訊.

留言

熱門文章

TourCard 開通全紀錄 台胞證 支付寶

[ 教學 ] 如何使用 Sourcetree 對 Github 進行版本控制 #Mac OS 版本控制