三种方法实现 Android 定制 RadioBuon 样式:使用 XML 文件进行定义/在 JAVA 代码中定义等
等,感兴趣的朋友可以参考下,希望可以帮助到你
三种方法
1.使用 XML 文件进行定义 res/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/tabswitcher_long" />
<!--选中->
<item
android:state_checked="true"
android:drawable="@drawable/tabswitcher_short" />
</selector>
在布局文件中使用
复制代码 代码如下:
<RadioGroup
...
>
<RadioButton
...
android:button="@null"
android:background="@drawable/radio"
/>
</RadioGroup>