創(chuàng)建一個viewgroup
public class KapCustomNextButton extends FrameLayout {
public KapCustomNextButton(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
View view = LayoutInflater.from(context).inflate(R.layout.view_custom_nextbutton,this);
ButterKnife.bind(this,view);
}
}
創(chuàng)建.xml(view_custom_nextbutton.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
創(chuàng)建自定義屬性屬性(res/value/attrs.xml 中KapCustomNextButton)
<resources>
<declare-styleable name="KapCustomNextButton">
<attr name="custon_nextbutton_title_normal" format="string|reference"/>
<attr name="custon_nextbutton_title_selected" format="string|reference"/>
<attr name="custon_nextbutton_title_unenable" format="string|reference"/>
<attr name="custon_nextbutton_titlecolor_normal" format="color|reference"/>
<attr name="custon_nextbutton_titlecolor_selected" format="color|reference"/>
<attr name="custon_nextbutton_titlecolor_unenable" format="color|reference"/>
<attr name="custon_nextbutton_backcolor_normal" format="color|reference"/>
<attr name="custon_nextbutton_backcolor_selected" format="color|reference"/>
<attr name="custon_nextbutton_backcolor_unenable" format="color|reference"/>
</declare-styleable>
</resources>
以上就是全部步驟
以下是細節(jié):