New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Elevation and border radius do not work well with opacity from Android 9 #25093
Comments
I think this is related to #23090 and react-navigation/react-navigation#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 |
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? |
@ferrannp hello sir, is there anyways to make this bug more priority. I am waiting for this too long sir. |
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. This was mentioned here: #23090 (comment) |
I have a function that resizes px size based on a device's width. |
What helped me when I wanted a wrapping element to have opacity and its children to have shadow and elevation while removing the buggy effect of seeing the border is that instead of applying the opacity through the opacity key (e.g., opacity: 0.7), I applied it through backgroundColor (e.g., '#FFFFFFB2'). This got rid of the effect for me. |
Using @simongoot solution, needsOffscreenAlphaCompositing worked great. In case someone else has the problem with a import { Pressable, Animated } from 'react-native';
const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
const Button = ({children}) => {
const animatedButtonOpacity = useRef(new Animated.Value(1));
const buttonOpacity = {
opacity: animatedButtonOpacity.current
};
return (
<>
{properties.map((property, index) => (
<AnimatedPressable
onPressIn={() => animatedButtonOpacity.current.setValue(0.5)}
onPressOut={() => animatedButtonOpacity.current.setValue(1)}
onPres={...}
style={buttonOpacity}
needsOffscreenAlphaCompositing
>
{children}
</AnimatedPressable>
))}
</>
);
}; |
Seems like |
Encountered, yes. Sorted, no. This is still a thing. So my guess is, this issue is still going on. Currently running the latest RN version, I might add. |
I discovered a simple way to fix the problem, which is adding an opacity property to the child component to overide the effect done by the parent element, such as |
This does not work for me, is there already another fix? |
Setting |
Any updates? I'm facing the same issue, and either |
Still buggy... |
Workaround was published here. Do you believe it worth fixing this issue in react-native? |
still facing 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.
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
The text was updated successfully, but these errors were encountered: