Material-components-android: [MaterialCheckBox] Ripples are red on Lollipop

Created on 6 May 2020  路  3Comments  路  Source: material-components/material-components-android

Description:

When colorControlHighlight is a ColorStateList with theme attributes, MaterialCheckBox ripples are red on Lollipop:

v22 | v29
---|---
light-before | v23

Expected behavior:

See v29^

Fixing this would require tinting the background programmatically, using AppCompatResources to load colorControlHighlight, rather than using it from XML.

Source code:

In the app theme, override colorControlHighlight to point to a CSL:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:alpha="0.12" android:color="?attr/colorPrimary" />
</selector>

Android API version:
21,22

Material Library version:
1.1.0, 1.2.0-alpha06

Device:
Emulator

To help us triage faster, please check to make sure you are using the latest version of the library.

We also happily accept pull requests.

bug

All 3 comments

Hi @ataulm, unfortunately globally setting colorControlHighlight to a CSL with theme attributes is not a safe thing to do, because that attribute is used in many places by many widgets (framework, AppCompat, etc.), and it's not guaranteed that they all use AppCompatResources to load the attribute.

E.g., in this case, the loading of colorControlHighlight isn't in MaterialCheckBox. I think it's in AppCompatCheckBox, so you may be able to file an AppCompat bug.

Ah yeah, we're doing it locally using materialThemeOverlay, I just simplified the example for this issue.

Thanks, I'll open it on the main bug tracker! :+1:

For others following along, submitted here - https://issuetracker.google.com/issues/155939564

Was this page helpful?
0 / 5 - 0 ratings