React Native:子视图不能超越 Android 上的父视图,但它可以在 iOS 上运行 [英] React native: children view cannot go beyond parent view on Android but it is working on iOS
问题描述
我在将我的应用程序从 iOS 移植到 android 时遇到了问题.我已经构建了一个可以重现的最小错误案例.
I have encountered a problem porting my app from iOS to android. I have built a minimal bug case with which it can be reproduced.
我的应用程序非常简单,由一个组件组成:
My app is very simple and consists of one component:
const Main = () => (
<View>
<View style= {styles.green}>
<View style={styles.blue}/>
</View>
</View>
)
export default Main;
const styles = StyleSheet.create({
green: {
height:200,
marginTop: 200,
backgroundColor: 'green',
},
blue:{
position:'absolute',
height: 100,
width: 100,
top: -50,
backgroundColor: 'blue',
},
})
但奇怪的是,这个组件在 iOS 和 Android 上的呈现方式不同
But strangely this component renders differently on iOS and Android
我希望它在两种设备上都像在 iOS 上一样呈现.您可以在此 repo https://github.com/42void/ReactNativeBug 上检查代码以轻松重现它.
I would like it to render like on iOS on both devices. You can check code on this repo https://github.com/42void/ReactNativeBug to easily reproduce it.
谢谢!
推荐答案
在 Android 中 overflow
属性默认为 'hidden'
且无法更改.
In Android overflow
property defaults to 'hidden'
and cannot be changed.
从 0.23 已知问题,显然还没有修复.
这篇关于React Native:子视图不能超越 Android 上的父视图,但它可以在 iOS 上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!