【问题标题】:Set size Radio Button android设置大小单选按钮android
【发布时间】:2017-10-15 08:41:30
【问题描述】:

我需要更改单选按钮圆圈的大小以及单击它时的颜色。它应该如下图所示。 你有什么想法或例子吗?谢谢

【问题讨论】:

  • 你试过什么代码?什么不工作?

标签: android radio-button background-color


【解决方案1】:

您可以尝试为单选按钮使用自定义可绘制背景作为示例 -

<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>

【讨论】:

    猜你喜欢
    • 2011-09-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-13
    • 2015-01-09
    • 1970-01-01
    • 1970-01-01
    • 2011-05-07
    • 1970-01-01
    相关资源
    最近更新 更多