Skip to content

[MaterialRadioButton, MaterialCheckBox, SwitchMaterial] Set text color in default style #1182

Closed
@ataulm

Description

@ataulm

Is your feature request related to a problem? Please describe.
MaterialRadioButton inherits the text color from Widget.CompoundButton, which sets it to an arcane attribute - ?android:attr/textColorPrimaryDisableOnly.

We can set this attribute in our theme or we can set android:textColor in the layout/our default style/style.

Describe the solution you'd like
Override android:textColor in Widget.MaterialComponents.CompoundButton.RadioButton:

<style name="Widget.MaterialComponents.CompoundButton.RadioButton" parent="Widget.AppCompat.CompoundButton.RadioButton">
    <item name="android:textColor">?attr/colorOnSurface</item>
</style>

Describe alternatives you've considered

For now, I've explicitly set a default style for the AppCompat/Material RadioButton:

<style name="Base.Theme.Monzo" parent="Platform.Theme.Monzo">
    <item name="radioButtonStyle">@style/Widget.Monzo.CompoundButton.RadioButton</item>
    ...
<style name="Widget.Monzo.CompoundButton.RadioButton"
        parent="Widget.MaterialComponents.CompoundButton.RadioButton">
    <item name="android:textColor">?android:attr/textColorPrimary</item>
</style>

Similar for checkbox and switch!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions