1.自定义属性定义的位置
在values文件夹下新建attrs.xml文件,可定义如下结构:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="titleText" format="string" />
<attr name="titleTextColor" format="color" />
<attr name="titleTextSize" format="dimension" />
<declare-styleable name="CustomTitleView">
<attr name="titleText" />
<attr name="titleTextColor" />
<attr name="titleTextSize" />
</declare-styleable>
</resources>
其中"format"可选的属性一共是:string,color,demension,integer,enum,reference,float,boolean,fraction,flag 这几种。
网友评论