Skip to content

[ElevationOverlay] Dark theme overlay not applied when using color state list #955

@claytongreen

Description

@claytongreen

Description:
When using MaterialShapeDrawable.createWithElevationOverlay() and adding it as the background to a view, it doesn't apply the semi-transparent overlay to indicate elevation if colorOnSurface is a color state list resource.

The test app has a night theme with colorOnSurface reference to a color state list resource that is used to set the alpha on a color:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:alpha="0.87" android:color="#fff" />
</selector>

There are 2 TextViews and they both have a MaterialShapeDrawable set as their background. The second one uses a theme overlay to illustrate the elevation overlay working with an argb color set as colorOnSurface.

<style name="ThemeOverlay.App.White87ARGB" parent="ThemeOverlay.MaterialComponents">
    <item name="colorOnSurface">#DEFFFFFF</item>
</style>

Expected behavior:
The background of colorOnSurface: @color/white_87 should match colorOnSurface: #DEFFFFFF.

Screenshot_1580244947

Source code:
https://github.com/claytongreen/elevation_overlay_bug

Android API version: 29

Material Library version: 1.2.0-alpha04

Device: API 29 Pixel 3 emulator

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions