在drawable中建立xml文档并导入图片:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_enabled="false"
android:state_checked="false"
android:state_pressed="false"
android:drawable="@drawable/rg3">
</item>
<item
android:state_enabled="false"
android:state_checked="true"
android:state_pressed="false"
android:drawable="@drawable/rg4">
</item>
<item
android:state_enabled="true"
android:state_checked="false"
android:state_pressed="false"
android:drawable="@drawable/rg1">
</item>
<item
android:state_enabled="true"
android:state_checked="true"
android:state_pressed="false"
android:drawable="@drawable/rg2">
</item>
</selector>
应用:
<RadioButton
android:id="@+id/radio_mipi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:button="@drawable/myradiobutton"
android:text="@string/str_mipi"
android:textSize="6sp"/>