效果图
activity_main.xml
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="@+id/rb_one"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/cus_radio"
android:drawablePadding="0dp"
android:drawableLeft="@android:drawable/star_on"
android:checked="true"
android:text="@string/str_one"/>
<RadioButton
android:id="@+id/rb_two"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/cus_radio"
android:drawableLeft="@android:drawable/star_on"
android:text="@string/str_two"/>
<RadioButton
android:id="@+id/rb_three"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/cus_radio"
android:drawableLeft="@android:drawable/star_on"
android:text="@string/str_three"/>
</RadioGroup>
style.xml
<style name="cus_radio">
<item name="android:button">@null</item>
<item name="android:gravity">center</item>
<item name="android:textColor">@color/white</item>
<item name="android:padding">@dimen/font_tiny</item>
<item name="android:background">@drawable/radio</item>
<item name="android:layout_weight">1</item>
<item name="android:layout_margin">5dp</item>
</style>
drawable/radio.xml
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false"
android:drawable="@drawable/btn_orange_normal_shape" />
<item android:state_checked="true"
android:drawable="@drawable/btn_orange_pressed_shape" />
</selector>
本文地址:https://blog.csdn.net/zhu_nana/article/details/108572754
您可能感兴趣的文章:
如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!
网友评论