一个简单单选按钮。
To get a Git project into your build:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
dependencies {
compile 'com.github.pwcong:RadioButtonView:v1.0.0'
}
<me.pwcong.radiobuttonview.view.RadioButtonView
android:id="@+id/rbv_1"
android:layout_width="500dp"
android:layout_height="100dp"
app:frameColor="#FF4081"
app:textColor="#FFFFFF"
app:strokeWidth="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="strokeWidth" format="dimension"/>
<attr name="frameColor" format="color"/>
<attr name="textColor" format="color"/>
</declare-styleable>