如何使用ImageBackground在react-native中为屏幕设置背景图像 [英] How to use ImageBackground to set background image for screen in react-native
本文介绍了如何使用ImageBackground在react-native中为屏幕设置背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我在react-native中使用时,它发出警告,不建议与孩子一起使用,将来会出错.而是用户.
When I use in react-native it gives warning that using with children is deprecated and will be error in future. User instead.
所以,如果使用
这是我为使用
<ImageBackground source={require('../../img/splash/splash_bg.png')} style={styles.backgroundImage} >
</ImageBackground>
样式代码是
const styles = StyleSheet.create({
backgroundImage: {
flex: 1,
// width: undefined,
// height: undefined,
// flexDirection: 'column',
// backgroundColor:'transparent',
// justifyContent: 'flex-start',
},}
时获得
推荐答案
您可以使用组件.
<ImageBackground
source={yourSourceFile}
style={{width: '100%', height: '100%'}}
>
<....yourContent...>
</ImageBackground>
这篇关于如何使用ImageBackground在react-native中为屏幕设置背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文