<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- 这里是自定义属性 -->
<attr name="position">
<enum name="left_top" value="0"/>
<enum name="left_bottom" value="1"/>
<enum name="right_top" value="2"/>
<enum name="right_bottom" value="3"/>
</attr>
<attr name="radius" format="dimension"/>
<!-- 这里是引用自定义属性,这个那么可以随便定义 -->
<declare-styleable name="ArcMenu">
<attr name="position"/>
<attr name="radius"/>
</declare-styleable>
</resources>
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ArcMenu, defStyle, 0);
/**
* 获取默认的位置
*/
int pos = ta.getInt(R.styleable.ArcMenu_position, POSITION_RIGHT_BOTTOM);
mRadius = (int) ta.getDimension(R.styleable.ArcMenu_radius,TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100, getResources().getDisplayMetrics()));
//mRadius = (int) ta.getDimension(R.styleable.ArcMenu_radius,100.0f);
ta.recycle();
获取attr属性文件中定义的属性,position 和radius是ArcMenu集合中的一个属性,那么 在getDimessIon中,引用是就是ArcMenu_position。系统就默认就是这个格式