參考:
Android Tools Attributes listItem 和 Sample Data 的用法
筆記
-
tools:text
TextView可以實現預覽,不影響實際的效果例如:
tools:text="測試"
-
tools:listitem
屬性值為一個layout
,就是item
的布局例如:
tools:listitem="@layout/item_direct_message"
- listitem可以引用的官方資源文件
屬性值 | 占位數據描述 |
---|---|
@tools:sample/full_names | 隨機生成的 @tools:sample/first_names and @tools:sample/last_names 的組合名稱 |
@tools:sample/first_names | 常用的名 |
@tools:sample/last_names | 常用的姓 |
@tools:sample/cities | 世界范圍內城市的名字 |
@tools:sample/us_zipcodes | 隨機生成的🇺🇸郵政編碼 |
@tools:sample/us_phones | 隨機生成的🇺🇸☎️號碼, 符合下面的格式: (800) 555-xxxx |
@tools:sample/lorem | 起源於拉丁文的占位文字 |
@tools:sample/date/day_of_week | 隨機的特定格式的日期和時間 |
@tools:sample/avatars | 可以用於人物頭像的 vector drawables |
@tools:sample/backgrounds/scenic | 可以用於背景的圖片 |
-
自定義資源文件
app點擊sample data directory
編譯APP不會將此目錄編譯
可以是txt文件或者是json文件
需要注意的是, 這里要求 JSON 文件開頭不能是
JsonArray
, 只能是JsonObject
. 創建完成后, 需要重新編譯一下才能引用到最新的數據.引用
tools:text="@sample/github_user.json/github_users/name[1]"