question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Elevation and border radius do not work well with opacity from Android 9

See original GitHub issue

The way elevation works is that it creates a border around the element that is then shifted to the bottom. The background color of the element then hides the inside part of the border.

When we apply border radius to the same element, the border gets thicker to accommodate for the increased radius. So far so good.

Unfortunately if we then apply the opacity to the parent, the background color of the element gets semitransparent, making the border visible and creating an ugly effect.

Screenshot_2019-05-30-17-03-34-477_host exp exponent

React Native version: 0.57 Expo SDK 32 Android version: 9.0

Steps To Reproduce

Create an element and apply, elevation, border radius and background color. Then apply opacity on its parent.

Describe what you expected to happen:

The border underneath the element should not leak out

Snack, code example, or link to a repository:

https://snack.expo.io/SJDAlu6TV

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:39
  • Comments:24 (3 by maintainers)

github_iconTop GitHub Comments

70reactions
WickedBratcommented, Sep 22, 2019

Using backgroundColor: '#fff' sets it right and works as expected.

27reactions
simongootcommented, Sep 17, 2020

I found that this problem occur when changing opacity on a wrapping element that contain child elements using elevation for shadow. What fixed this bug for me temporarily was to set flag needsOffscreenAlphaCompositing on the wrapping element that i animated opacity style prop for. (For best practice usage check: https://reactnative.dev/docs/view#needsoffscreenalphacompositing) Otherwise setting opacity on each of the child elements should also work, instead of only the parent wrapper.

This was mentioned here: https://github.com/facebook/react-native/issues/23090#issuecomment-669157170

Read more comments on GitHub >

github_iconTop Results From Across the Web

border radius in react native not working - Stack Overflow
It's React Native bug. Elevation and border radius do not work well with opacity from Android 9.
Read more >
filter - CSS: Cascading Style Sheets - MDN Web Docs - Mozilla
Filters are commonly used to adjust the rendering of images, backgrounds, and borders. Included in the CSS standard are several functions that ...
Read more >
border-radius - CSS-Tricks
You can give any element "rounded corners" by applying a border-radius through CSS. You'll only notice if there is a color change involved....
Read more >
USS common properties - Unity - Manual
If height is not specified, the height is based on the height of the element's contents. ... Border radius properties work almost the...
Read more >
Adding Border-Radius to Slider via custom CSS
Thanks to everyone on this - in the end the solution was within the Edit Creative area. You can set the main container...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found