1.在values目录下创建一个attrs.xml文件
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="SettingItemView">
<!-- 标题 -->
<attr name="title" format="string" />
<!-- 背景 -->
<attr name="background">
<enum name="black" value="0" />
<enum name="white" value="1" />
<enum name="red" value="2" />
</attr>
</declare-styleable>
</resources>
//注:上面的配置方法完全是模仿Android sdk的配置方法
2.在布局文件中配置命名空间
xmlns:test(随便起个名字)="/apk/res/com.test(包名)"
3.在自定义控件下就可以使用了
test:title = "test" // 给自定义控件设置title
test:background = "red" // 给自定义控件设置背景