Tools命名空间属性说明
tools:node
tools:node=”merge” 全部合并
tools:node=”merge-only-attributes” 仅合并属性,内部节点移除
tools:node=”remove” 移除该节点
tools:node=”removeAll” 移除同一个父节点下所有同类型节点
tools:node=”replace” 完全替换
tools:node=”strict” 不匹配,构建失败
tools:remove
tools:remove=”attr1,attr2” 比如 tools:remove=”android:theme,android:windowSoftInputMode”
tools:strict
tools:strict=”attr1,attr2” 比如 tools:strict=”android:screenOrientation”
tools:selector
tools:selector=”packageName” 选择器,结合其他tools标记使用,比如
1 |
|
tools:overrideLibrary
tools:overrideLibrary 覆盖
1 |
|
tools:ignore
tools:ignore=”attr1,attr2” 忽略属性
1 |
|
tools:targetApi
tools:targetApi=”14” tools:targetApi=”ice_cream_sandwich” 目标平台版本
1 |
|
tools:locale
tools:locale 指定时区,只能加给resources节点
1 |
|
tools:shrinkMode
tools:shrinkMode 指定资源压缩模式,只能加给resources节点,需要build.gradle中android.buildTypes.release.shrinkResources = true
tools:shrinkMode=”safe”默认
tools:shrinkMode=”strict”res/raw/keep.xml
1 |
|
tools:keep & tools:discard
以下两个结合tools:shrinkMode=”strict”使用
tools:keep=”references” 保留 tools:keep=”@layout/list_item_*,@menu/main_menus”
tools:discard=”references” 移除 tools:discard=”@layout/unused*”
tools:parentTag
tools:parentTag 父标签类型,结合merge使用
1 |
|
tools:context
tools:context=”com.example.XXXActivity” 指定当前关联上下文,只能在根节点添加
list
tools:itemCount=”20”
tools:listheader=”@layout/list_header_0” 指定表头,仅AdapterView有效
tools:listitem=”@layout/list_item_0”
tools:listfooter=”@layout/list_footer_0” 指定表尾,仅AdapterView有效
tools:layout
tools:layout=”@layout/some_layout”
tools:showIn
tools:showIn=”@layout/some_parent_layout” 在哪个布局中展示,通过include引入的布局的根节点添加
tools:menu
tools:menu=”menu1,menu2” 指定工具栏菜单,根节点添加
tools:actionBarNavMode
ActionBar显示模式
tools:actionBarNavMode=”standard”
tools:actionBarNavMode=”tabs”
tools:actionBarNavMode=”list”
NumberPicker
NumberPicker的最大最小值
tools:minValue
tools:maxValue
DrawerLayout
tools:openDrawer=”start”
tools:openDrawer=”end”
tools:openDrawer=”left”
tools:openDrawer=”right”
<androidx.drawerlayout.DrawerLayout tools:openDrawer=”end”/>
TextView
tools:text
@tools:sample/*
@tools:sample
@tools:sample/full_names
@tools:sample/first_names
@tools:sample/last_names
@tools:sample/cities
@tools:sample/us_zipcodes
@tools:sample/us_phones
@tools:sample/lorem/random
@tools:sample/date/day_of_week
@tools:sample/date/ddmmyy
@tools:sample/date/mmddyy
@tools:sample/date/hhmm
@tools:sample/date/hhmmss
@tools:sample/avatars – drawables
@tools:sample/backgrounds/scenic – backgrounds
sampledata
app/sampledata/names
ImageView
tools:src
app/sampledata/avatars
app/sampledata/avatars/avatar_1.xml
app/sampledata/avatars/avatar_2.xml
app/sampledata/avatars/avatar_3.xml
app/sampledata/avatars/avatar_4.xml
app/sampledata/users.json
1 |
|
1 |
|