【问题标题】:How to change the outline size of the RadioButton如何更改 RadioButton 的轮廓大小
【发布时间】:2018-07-05 12:07:05
【问题描述】:

我在我的应用程序中使用RadioButtons,它看起来很大而且厚度也很高。我想知道有没有办法减少轮廓厚度?

<RadioGroup
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/statusRadioGroup"
    android:buttonTint="@color/order_inprocess"
    android:checkedButton="@+id/radioActive"
    android:orientation="horizontal">

    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/radioActive"
        android:textColor="@color/order_inprocess"
        android:layout_weight="1"
        fontPath="fonts/Roboto-Regular.ttf"
        app:buttonTint="@color/order_inprocess"
        android:textSize="14dp"
        android:text="Active" />

    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:id="@+id/radioDeactive"
        android:textColor="@color/order_inprocess"
        fontPath="fonts/Roboto-Regular.ttf"
        app:buttonTint="@color/order_inprocess"
        android:textSize="14dp"
        android:text="Deactive" />

</RadioGroup>

【问题讨论】:

    标签: android android-layout radio-button


    【解决方案1】:

    您必须创建自定义可绘制对象。

    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:button="@drawable/custom_radio_button"/>
    
    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:drawable="@drawable/custom_radio_button_checked"
        android:state_checked="true" />
        <item android:drawable="@drawable/custom_radio_button_unchecked" />
    </selector>
    

    如果您对动画感兴趣,请查看StateListAnimatorAnimatedVectorDrawable

    https://developer.android.com/training/material/animations.html#ViewState

    【讨论】:

      【解决方案2】:

      你不能从 android studio 编辑图标收音机,你可以使用来自 http://flaticon.com/ 的图标绘制

      【讨论】:

        猜你喜欢
        • 2011-03-02
        • 2018-06-16
        • 2019-12-24
        • 2021-11-09
        • 2021-06-17
        • 2018-11-21
        • 1970-01-01
        • 2014-10-16
        相关资源
        最近更新 更多