I currently have FrameLayout with the following code upon initialization in its init function
val bgDrawable = MaterialShapeDrawable.createWithElevationOverlay(context).apply {
fillColor = ColorStateList.valueOf(Color.WHITE)
}
ViewCompat.setBackground(this, bgDrawable)
When the elevation is 0, the background renders correctly white
However, when I set the elevation to greater than 0, the background becomes gray.
Somethings that I tried was setting the tint to white, but, that seems to get rid of the elevation shadow of the MaterialShapeDrawable
Goal:
I just want a White MaterialShapeDrawable background value on a FrameLayout and when elevation is > 0, to stay white with the elevation shadow intact
It depends by the elevation overlay color and it happens only if the current theme's attribute
elevationOverlayEnabledistrueand thebackgroundColor(fillColor) matches the theme's surface color (colorSurfaceattribute).If you want to avoid this behavior you can set in your app theme:
Check in particolar way the app theme in the dark mode where this attribute is
trueby default.