Elevation in a View with transparent background

后端 未结 1 1571
孤街浪徒
孤街浪徒 2021-01-17 22:11

I have a list of items with a custom background. The background is a simple shape with rounded-rect drawable filled with white color. So my view is similar to a Card. I can

1条回答
  •  攒了一身酷
    2021-01-17 22:55

    I believe this to be related to a known issue in Lollipop https://code.google.com/p/android/issues/detail?id=78248

    Thanks for the report and repro steps - this is indeed a bug, and it has just been fixed in an internal branch. Will be released externally in a future release.

    As a workaround, you can either set an alpha on the GradientDrawable, or set a custom outline provider on the view casting the shadow (via View#setOutlineProvider) to query the outline from the background and override the alpha provided by the drawable.

    The issue was that GradientDrawable was being too conservative in reporting a 0 alpha in cases where it had a transparent fill. (See GradientDrawable#getOutline(), for the curious)

    0 讨论(0)
提交回复
热议问题