<RadioGroup
android:id="@+id/rg"
android:layout_width="match_parent"
android:layout_height="128dp"
android:layout_gravity="center_vertical|center"
android:orientation="horizontal">
<RadioButton
android:id="@+id/rb_line1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/rb_selector_title"
android:button="@null"
android:checked="true"
android:gravity="center"
android:text="线路一"
android:textColor="@drawable/rb_color_text3"
android:textSize="30px" />
<RadioButton
android:id="@+id/rb_line2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/rb_selector_title"
android:button="@null"
android:gravity="center"
android:text="线路二"
android:textColor="@drawable/rb_color_text3"
android:textSize="30px" />
</RadioGroup>
文字选择器<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="#c40d23"/>
<item android:state_checked="false" android:color="#666666"/>
</selector>
背景选择器
<?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
>
<item android:drawable="@drawable/shape_tab_border3" android:state_checked="true" />
<item android:drawable="#FFFFFF" />
</selector>
使用selector画背景图
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 连框颜色值 -->
<item>
<shape>
<solid android:color="#c40d23" />
</shape>
</item>
<!-- 主体背景颜色值 -->
<item android:bottom="4dp"> <!--设置只有底部有边框-->
<shape>
<solid android:color="#ffffff" />
</shape>
</item>
</layer-list>
效果图