@act262
2017-08-09T12:39:49.000000Z
字数 1332
阅读 979
theme
对应文件/res/values/attrs.xml
<resources><!--熟悉的主题中的属性 --><declare-styleable name="Theme">...<attr name="windowBackground" format="reference" /><attr name="windowNoTitle" format="boolean" /><attr name="windowFullscreen" format="boolean" />...</declare-styleable><!-- 熟悉的View的属性 --><declare-styleable name="View"><attr name="id" format="reference" /><attr name="background" format="reference|color" />...</declare-styleable>...</resources>
在内部声明、外部声明属性
i.e. 在外部声明了orientation属性,然后在LinearLayout的内部中直接引用
<attr name="orientation"><enum name="horizontal" value="0" /><enum name="vertical" value="1" /></attr>
<declare-styleable name="LinearLayout"><attr name="orientation" />...<declare-styleable>
也可以把orientation属性放到LinearLayout内部声明
<declare-styleable name="LinearLayout"><attr name="orientation"><enum name="horizontal" value="0" /><enum name="vertical" value="1" /></attr>...<declare-styleable>
外部声明的属性可以在多个地方引用,内部声明的属性只能在当前样式引用
对应的文件/res/values/themes.xml
<resources><style name="Theme"><!-- Window attributes --><item name="windowBackground">@drawable/screen_background_selector_dark</item><item name="windowNoTitle">false</item><item name="windowFullscreen">false</item></style><style name="Theme.Light"><item name="windowBackground">@drawable/screen_background_selector_light</item></style>
可以给Activity指定不同主题样式
