Tag: declare styleable

在Android中声明样式属性

有关于declare-styleable标签的珍贵的小文档,我们可以通过它来声明组件的自定义样式。 我确实find了attr标签的format属性的有效值列表 。 虽然这是很好的,但它并没有解释如何使用其中的一些值。 浏览attr.xml (标准属性的Android源代码),我发现你可以做如下的事情: <!– The most prominent text color. –> <attr name="textColorPrimary" format="reference|color" /> format属性显然可以设置为值的组合。 format属性可能帮助parsing器解释实际的样式值。 然后我在attr.xml中发现了这个: <!– Default text typeface. –> <attr name="typeface"> <enum name="normal" value="0" /> <enum name="sans" value="1" /> <enum name="serif" value="2" /> <enum name="monospace" value="3" /> </attr> <!– Default text typeface style. –> <attr name="textStyle"> <flag name="normal" value="0" […]