material-components / material-components-android

Modular and customizable Material Design UI components for Android
Apache License 2.0
16.38k stars 3.07k forks source link

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

Closed ataulm closed 2 years ago

ataulm commented 4 years ago

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!

drchen commented 2 years ago

Hi folks, I confirmed with our designers and they are leaning toward not to define the default color of the associated labels of compound buttons. With the Material themes we actually point ?android:attr/textColorPrimaryDisableOnly to ?attr/colorOnBackground btw.

In the meantime they are looking into adding more detailed design guidelines regarding the compound button labels on our website.

I'll close this issue for now. : )