一般的我们在attrs.xml中定义我们自己控件的属性,demo如下:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="tbTextColor" format="reference|color"/>
<attr name="tbTextSize" format="dimension|reference"/>
<attr name="tbBackground" format="reference|color"/>
<attr name="tbText" format="reference|string"/>
<attr name="tbIcon" format="reference"/>
<declare-styleable name="TBView">
<attr name="tbTextColor"/>
<attr name="tbTextSize"/>
<attr name="tbBackground"/>
<attr name="tbText"/>
<attr name="tbIcon"/>
</declare-styleable>
</resources>
对于上述的demo,其中的format可以是以下类型: