Material-components-android: [Widget.MaterialComponents.Button.TextButton] `rippleColor` is not working when set from styles for `MaterialAlertDialog`

Created on 19 Dec 2019  路  6Comments  路  Source: material-components/material-components-android

RippleColor is not working for MaterialAlertDialog

I had setup a theme as:

<style name="Material.Dialog.Alert" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
        <item name="buttonBarPositiveButtonStyle">
            @style/Material.Dialog.Alert.Button.Positive
        </item>
    </style>

for the MaterialAlertDialog:
<item name="materialAlertDialogTheme">@style/Material.Dialog.Alert</item>

and a TextButton styles as:

<style name="Material.Dialog.Alert.Button.Positive" parent="Widget.MaterialComponents.Button.TextButton">
        <item name="rippleColor">@color/link_primary</item> //This property doesnt have any effect
        <item name="android:textColor">@color/link_primary</item>
    </style>

Parent theme: Theme.MaterialComponents.Light.NoActionBar.Bridge

Android API version: 21, 25, 28, 29

Material Library version: com.google.android.material:material:1.1.0-alpha04 (Didnt see any fix on the new releases documentation though)

bug

Most helpful comment

This is not working with the latest version (1.2.0-alpha03) too if the parent theme is Theme.MaterialComponents.Light.NoActionBar.Bridge

It works, if parent theme is Theme.MaterialComponents.Light.NoActionBar though

_I mean the ripple effect for MaterialAlertDialog is not working at all (even the default one - mtrl_btn_text_btn_ripple_color.xml) when the parent theme is set to Theme.MaterialComponents.Light.NoActionBar.Bridge_

All 6 comments

What does @color/link_primary look like?

Does it use a similar structure as our default text button ripple color?

https://github.com/material-components/material-components-android/blob/master/lib/java/com/google/android/material/button/res/color/mtrl_btn_text_btn_ripple_color.xml

Does setting rippleColor to your @color/link_primary on a text button outside of a MaterialAlertDialog work?

Can you try with the latest version of the Material library just to make sure the issue hasn't been fixed?

Removing rippleColor at all, it doesnt work either. Shouldnt it fallback to the mtrl_btn_text_btn_ripple_color.xml selector you referenced?

It tried both with a similar structure (selector) and a _color resource_ and it doesnt work

Using rippleColor on a text button outside MaterialAlertDialog works with @color/link_primary

This is not working with the latest version (1.2.0-alpha03) too if the parent theme is Theme.MaterialComponents.Light.NoActionBar.Bridge

It works, if parent theme is Theme.MaterialComponents.Light.NoActionBar though

_I mean the ripple effect for MaterialAlertDialog is not working at all (even the default one - mtrl_btn_text_btn_ripple_color.xml) when the parent theme is set to Theme.MaterialComponents.Light.NoActionBar.Bridge_

Any news?
Tested with 1.2.0-beta01 bug still exists

On 1.1.0 everything is working fine

Removing rippleColor at all, it doesnt work either. Shouldnt it fallback to the mtrl_btn_text_btn_ripple_color.xml selector you referenced?

It tried both with a similar structure (selector) and a _color resource_ and it doesnt work

Using rippleColor on a text button outside MaterialAlertDialog works with @color/link_primary

I am not sure it is a bug.
You are using a Bridge theme. It means that the buttons inside the AlertDialog are AppCompatButton instead of MaterialButton.

Schermata 2020-08-15 alle 20 54 23

The rippleColorattribute is known at AppCompatButton and it is not used at all.
If you want to change the rippleColor you can use something like:

<style name="Material.Dialog.Alert" parent="ThemeOverlay.MaterialComponents.Dialog.Alert">
    <item name="buttonBarPositiveButtonStyle">@style/Widget.AppCompat.Button.Borderless</item>
    <item name="buttonBarNegativeButtonStyle">@style/Widget.AppCompat.Button.Borderless</item>
    <item name="colorControlHighlight">@color/....</item>
</style>
Was this page helpful?
0 / 5 - 0 ratings