attrs中
?xml version=”1.0” encoding=”utf-8”?
resources
declare-styleable name=”MyCustom”
attr name=”progressColor” format=”color”
attr name=”textSize” format=”dimension”
attr name=”ringSize” format=”dimension”
attr name=”radiuSize” format=”dimension”
declare-styleable
resources
布局中
com.example.e9cponmeasure.MyCustom
android:id=”@+id/mc”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
custom:ringSize=”20dp”
custom:progressColor=”@android:color/holo_orange_dark”
custom:radiuSize=”150dp”
custom:textSize=”20sp”
android:background=”@android:color/holo_red_light”
android:layout_centerInParent=”true”
Java类
public class MyCustom extends View {
Paint paint;