【发布时间】:2017-10-15 08:41:30
【问题描述】:
我需要更改单选按钮圆圈的大小以及单击它时的颜色。它应该如下图所示。 你有什么想法或例子吗?谢谢
【问题讨论】:
-
你试过什么代码?什么不工作?
标签: android radio-button background-color
我需要更改单选按钮圆圈的大小以及单击它时的颜色。它应该如下图所示。 你有什么想法或例子吗?谢谢
【问题讨论】:
标签: android radio-button background-color
您可以尝试为单选按钮使用自定义可绘制背景作为示例 -
<RadioButton
android:id="@+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/custom_drawable_toggle_background"
android:button="@null"
android:checked="true"
android:text="RadioButton" />
在你的drawable中创建你的custom_drawable_toggle_background.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/custom_drawable_background_selected" android:state_checked="true"/>
<item android:drawable="@drawable/custom_drawable_background_unselected" android:state_checked="false"/>
</selector>
【讨论】: