一个简单单选按钮。
see https://jitpack.io/#pwcong/RadioButtonView
<com.github.pwcong.radiobuttonview.RadioButtonView
android:id="@+id/rbv_1"
android:layout_width="500dp"
android:layout_height="100dp"
app:frame_color="#FF4081"
app:text_color="#FFFFFF"
app:stroke_width="6dp"
app:margin="12dp"
/>
protected void onCreate(Bundle savedInstanceState) {
...
rbv = (RadioButtonView) findViewById(R.id.rbv_1);
rbv.setOptions(getArrayList());
rbv.setOnRadioButtonChangedListener(new RadioButtonView.OnRadioButtonChangedListener() {
@Override
public void onRadioButtonChanged(String option, int index) {
// Todo
}
});
}
private ArrayList<String> getArrayList(){
...
}
<declare-styleable name="RadioButtonView">
<attr name="margin" format="dimension"/>
<attr name="stroke_width" format="dimension"/>
<attr name="frame_color" format="color"/>
<attr name="text_color" format="color"/>
</declare-styleable>