react-native: borderRadius is never applied on Android when image contains another component
While working perfectly on iOS, border radius is never applied to an image if it contains any other component:
<Image style={ { borderRadius: 10, width: 300, height: 100 } } source={{ uri: 'https://placekitten.com/300/100' }}> <Text>SampleText</Text> </Image>
ios:
android:
I am using RN 0.29.0, and this is happening across all Android devices. I am currently building from osx
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 42
- Comments: 26 (1 by maintainers)
Managed to solve the problem using the
borderRadius
attribute on the Image instead of providing as style. RN 0.40using .54 and issue still exsists on android
This was fixed in RN 0.50.4
I managed to get around this by having the Text after the image and setting it to
absolute/top:0
.This could could probably be fixed by using RN 0.30.0 (see v0.30.0 release notes )
this fixes for me
<ImageBackground source={{ }} borderRadius={20}> <Text>Placeholder Text</Text> </ImageBackground>
I am using RN 0.51.0 and issue still persists
0.55 and still exists on android.
I tried it on RN 0.30 and on 0.31 RC, behavior doesn’t change.
@yazgazan seems to be reasonable workaround
I’d imagine the “fix” for this would be to wrap the image in a view that contains border radius instead. Eg.
<View style = {{flex: 1, borderRadius: 10}} ><Image style={ {width: 300, height: 100 } } source={{ uri: 'https://placekitten.com/300/100' }}> <Text>SampleText</Text> </Image> </View>