1.属性声明
<declare-styleable name="MyNumberPicker">
<attr name="my_Height" format="reference|dimension" />
<attr name="my_ShowDivider" format="reference|boolean" />
<attr name="my_Color" format="reference|color" />
</declare-styleable>
2.布局文件中引用
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.zcn.numberpicker.MyNumberPicker
app:my_Height="160dp"
app:my_ShowDivider="true"
app:my_Color="@color/white"/>
</RelativeLayout>
3.在style中引用
注:属性前千万不要加入app命名空间
<style name="MyNumberPicker">
<item name="my_Height">160dp</item>
<item name="my_ShowDivider">true</item>
<item name="my_Color">@color/white</item>
</style>