-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
View will lost background color when set borderRadius and height is large enough on Android device #15826
Comments
I have the same proble. Any resolution? |
Also getting this. I'm using simple Material Design card views. 2px border radius and a white background color set to a View element. If the card is long, it drops the background color and the background grey color shows through. |
Also worth noting that this does not happen using Genymotion - only with an actual device (Motorola Moto G). |
Tried updating to the latest Android on my device - this is still happening. I guess I'll be forced to remove the border radius on my Android cards until this is addressed. If anyone knows of a workaround, please let me know! |
I got the same problem.... it is confusing because i have many large height views in my app |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions. |
Hey now! I'm not sure if this should be marked stale yet. |
Really common use case that I ran into is standard material design guidelines for 'Card' components, with dynamic content. If the content got long...the background color magically disappeared!! Really gives an engineer credibility after they've pitched react native to a client. So yeah...I'd review this one before closing it! |
I am suffering from this bug too. I'm going to see if it's possible to simulate a tall box with rounded corners by having a short header view rounded top corners and no bottom border, then a resizing tall middle row with just left/right border, and a short bottom row with rounded bottom corners and no top border. |
That didn't work. It won't render the left/top/right borders when I set borderBottomWidth: 0. |
This should still be open. Anyone want to write a bot to fight all these overeager fb bots and keep issues open? 😂 |
This issue is still happening. It is happening for ScrollView in my case. |
This comment has been minimized.
This comment has been minimized.
I'm having this issue as well. I have created an example: https://snack.expo.io/@rkbhochalya/rn-view-background-color-issue. Try changing the |
@hramos could you please reopen this one? Still an issue in 0.55.4
|
@mjmasn can you confirm this is still an issue in |
@hramos It most certainly is, although I can only see it appearing on Android emulators and not on iOS emulators. |
This comment has been minimized.
This comment has been minimized.
I added borderColor and borderWidth to the following example: https://snack.expo.io/BkIGFyGNX |
+1 react-native: 0.48.4 I was just using a |
Thanks @hushicai, though we're only interested in repros in 0.56 or newer. 0.56 is the current release as of this writing. |
Update: This issue exists in Android 4.2 and below (API level 17 and below). @hramos another super weird one that seems related - seems on Android 4 devices (4.1.2 tested) the background (edit: and the stroke) vanishes if the view is 32px or more wider than the screen width. Our view needs to be const styles = StyleSheet.create({
thing: {
position: 'absolute',
backgroundColor: '#000',
}
}); render() {
const {width, height} = Dimensions.get('window');
// Working
return (
<View>
<View style={[styles.thing, {
height,
width: width + 31,
borderTopLeftRadius: 10,
borderTopRightRadius: 10,
}]} />
</View>
);
} render() {
const {width, height} = Dimensions.get('window');
// Background disappears
return (
<View>
<View style={[styles.thing, {
height,
width: width + 32,
borderTopLeftRadius: 10,
borderTopRightRadius: 10,
}]} />
</View>
);
} We're on RN 0.56.0 now so I can confirm this is still an issue - will try 0.57.0 once it's officially released.
|
Same here when rendered a View with borderRadius inside ScrollView |
Assuming you're applying the rounded corners to an entire list, this could be circumvented if the header and footer of a scrollview were positioned above and below the ScrollContentContainerViewClass. Right now applying the style to the contentContainerStyle will often produce the same effect. But if there was a way to render the header and footer outside of the container view and apply separate styling you could make them short enough to apply the rounded corners to them if need be. Either that or add an extra class to the inner list content which does not include the header and footer. |
This comment has been minimized.
This comment has been minimized.
Reproducable on RN 61.1, Pixel 3, API 23 emulator, but as far as remember could reproduce on physical devices with higher Android also |
Still a problem in rn 0.61.2 with Samsung Galaxy s7 |
Same issue: after upgrading to RN 0.61.2, i am losing the background of many elements. Update: we are using NativeBase "Content", so it's the same as everyone: "Scrollview" containing childs with a background + radius looses the background. Wrapping everything with two views + overflow hidden is not viable in my opinion as there is too many views concerned. |
Tried to solve this issue generally with my |
I used @fartymonk's solution as well, making an AndroidFixWrapper component that's styled only if Component: import React, { useMemo } from 'react';
import { View, Platform } from 'react-native';
import stylesFactory from './AndroidFixWrapper.styles';
export default ({
children,
type,
}: {
children: React.ReactChild;
type?: 'bigIcon' | 'button' | // etc;
}) => {
const styles = useMemo(() => stylesFactory(type), []);
return (
<View style={Platform.OS === 'android' && styles.androidContainer1}>
<View style={Platform.OS === 'android' && styles.androidContainer2}>
{children}
</View>
</View>
);
}; styles: import { StyleSheet, ViewStyle } from 'react-native';
interface WrapperStyle {
width?: string | number;
height?: string | number;
}
const containers = type => {
switch (type) {
case 'bigIcon': return [
{
width: '100%',
height: 120,
},
{
height: 100,
width: 120,
},
];
// etc...
export default type => {
const [ androidContainer1, androidContainer2 ]: WrapperStyle[] = containers(type);
const center = {
justifyContent: 'center' as ViewStyle['justifyContent'],
alignItems: 'center' as ViewStyle['alignItems'],
};
const transparentBackground = { backgroundColor: 'rgba(0, 0, 0, 0.001)' };
return StyleSheet.create({
androidContainer1: {
...androidContainer1,
...center,
},
androidContainer2: {
...androidContainer2,
...center,
...transparentBackground,
},
});
}; In use: <AndroidFixWrapper type="bigIcon">
<BigIcon
// etc...
/>
</AndroidFixWrapper>
Hope this gets figured out soon, but seeing that this thread is two years old and going strong, it's either a really tricky problem or not a priority. Or both. |
Using an android My component also loses its border properties, not only the background color. Since I need the border color and width, @fartymonk's solution is not really applicable. I can think of a few unholy solutions for my case, tho. |
Same with me! React Native version: 0.61.5 |
Using a physical device (Samsung Galaxy S7) with Android 8.0.0 and it happens for me with using border-radius bigger than 0 and a component height bigger than 2000px. Everything below is okay. Like @marcosalles mentioned it looses the border-radius and backgroundColor properties. |
I had a similar issue where the background color of components that were wrapped in a ScrollView disappeared (only on android device) when the ScrollView had a
In another case, the same problem appeared (again only android device) when a ScrollView with
|
Same with me! React Native version: 0.62.0 |
I have also had this issue of backgroundColor problem, I fixed it by just passing the background color to scrollView, and it is happening when height of the content increases.
|
After 3 years ... |
still an issue |
facing same issue v0.62.2 |
Still an issue in react-native 0.62.2 |
Glad to see that after hours of googling, others are having the same issue as well. I set the borderRadius property to 0 and it resolves the issue; however, I wish i could keep my rounded corners >.< |
If you use the
It will be fine. |
Same still happening lol using expo version 38.0.8, i got this bug testing my app on lg k8 running android 8.1, but also tested on android emulator running android 8.1 but there was no bug on the emulator, this bug is so random lol. I have solved the problem now with using 2 views and the inner view having the background color along with overflow hidden and the outer view having the border radius and that seems to work good enough for me.
styles
|
Having this issue with react native version 0.63.2, only on android, iOS is working fine, even the error messages and warnings are changing the background color |
react native HEAD at fabOnReact/react-native@41b6884 facebook/react-native#15826 **<details><summary>CLICK TO OPEN TESTS RESULTS</summary>** <p> <image src="https://user-images.githubusercontent.com/24992535/106642575-d21cea00-6588-11eb-9a97-3dea694237ff.png" width="200" /> <image src="https://user-images.githubusercontent.com/24992535/106642580-d3e6ad80-6588-11eb-8acd-6ce95105db71.png" width="200" /> <image src="https://user-images.githubusercontent.com/24992535/106642592-d5b07100-6588-11eb-8755-5621fbffbe67.png" width="200" /> </p> </details>
I tried to reproduce this both in the rn-tester project and in a separate project https://github.com/fabriziobertoglio1987/AwesomeProject/tree/15826 I built the project using the latest react-native master HEAD commit fabOnReact@41b6884 I also checked the node_modules, the commit was there and could not reproduce the issue on API 28. I remain available. Thanks a lot ☮️
|
It is still an issue on Android where elevation and borderRadius are used on a long list. Not reproduced on all the devices and it's pretty random. |
React Native 0.69.5 - still an issue |
react-native: 0.64.3 - still an issue |
react native 0.71 - still an issue |
6 years later 😅... |
I had the same issue today and none of the solution below not worked for me. After I used
|
Is this a bug report?
Yes
Have you read the Contributing Guidelines?
No
Environment
@mjmasn's environment:
@beiming's environment:
Steps to Reproduce
Run
react-native run-android
on a device, it does not reproduce on an AVD.Expected Behavior
It will be show a long view, with red background, and scroll view show
Test
in center.Actual Behavior
It will be show a long view, but no background color (white, maybe transparent), and scroll view show
Test
in center.The text was updated successfully, but these errors were encountered: