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.
React Native version: 0.57
Expo SDK 32
Android version: 9.0
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:
I think this is related to https://github.com/facebook/react-native/issues/23090 and https://github.com/react-navigation/react-navigation/issues/5535.
Seems like the issue is reproducible only on Android version 9.0 (I was testing that bug also on Android version 7.0 and 8.1 where it looks properly).
Facing this issue with RN 0.59.8 as well.
Tested on 0.59.9 and got the same problem as well. That makes the app really ugly on Android 9
Still facing the issue on RN 0.60.4
Still happening for me too, and have not found a workaround yet either.
Still an issue.
Using backgroundColor: '#fff'
sets it right and works as expected.
Still not work well.
I'm having the same issue with RN 0.61.4 ... no possible fix or workaround?
PS: I got the issue on Android 7.1.1 as well as Android 9
Having the same problem, when fading out with opacity, the back shadow looks unaceptable. Any updates on this?
Hi there! Same issue, look at this:
It looks good on a 5.5" display with Android Pie. Instead on a 6.67" display with Android Q it looks like in the image.
Style props:
{
width: 70, height: 70,
flexDirection: "row", justifyContent: "center", alignItems: "center",
backgroundColor: "#10aaae",
borderStyle: "solid",
borderRadius: 50,
borderWidth: 7,
borderColor: "rgba(16, 170, 174, 0.2)",
elevation: 10,
shadowColor: "#10aaae",
shadowRadius: 7,
shadowOpacity: .5,
shadowOffset : { width: 0, height: 10 }
}
Hope it could help in resolving! 馃馃徎
@ferrannp hello sir, is there anyways to make this bug more priority. I am waiting for this too long sir.
Using
backgroundColor: '#fff'
sets it right and works as expected.
worked for me, what happened was my component was transparent hence i can see whats happening in the back, setting a background color makes it work as intended
Using
backgroundColor: '#fff'
sets it right and works as expected.worked for me, what happened was my component was transparent hence i can see whats happening in the back, setting a background color makes it work as intended
The problem is that if you lower or animate the opacity of this element, fading it out, the background color doesn't help. You can still see the shadow being rendered underneath, like a thick border.
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
Most helpful comment
Using
backgroundColor: '#fff'
sets it right and works as expected.