changing radio button text color in style

时间:2017-12-18 06:14:46

标签: android radio-button

I tried to change radiobutton textcolor as follows,(since textcolor in theme is not applied for radiobutton, I added it as separate style)

<style name="BlueTheme" >
        <item name="android:background">#B0E0E6</item>
        <item name="android:textColor">#ffffff</item>
        <item name="android:radioButtonStyle">@style/mystyletwo</item>
    </style>
    <style name="mystyletwo">
        <item name="android:textColor">#ffffff</item>
    </style>

The problem is , textcolor is changed but the circle button is not visible.

2 个答案:

答案 0 :(得分:3)

Try this use android:buttonTint

Tint to apply to the button graphic.

May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb".

<RadioButton
    android:layout_width="match_parent"
    app:buttonTint="@color/colorAccent"
    android:layout_height="wrap_content" />

答案 1 :(得分:3)

Try this

 <item name="android:tint">#ffffff</item>

(or)

you can try this

 <android.support.v7.widget.AppCompatRadioButton
        android:id="@+id/rbtn_test"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:buttonTint="@color/primary" />

(or) add parent theme

 parent="Base.Widget.AppCompat.CompoundButton.RadioButton"

please add this line your style.