gpt4 book ai didi

javascript - 如何使用 ImageBackground 为 react-native 中的屏幕设置背景图像

转载 作者:行者123 更新时间:2023-12-03 10:09:03 28 4
gpt4 key购买 nike

当我在 react-native 中使用时,它会警告说不推荐使用与 child 一起使用,并且将来会出错。取而代之的是用户。

所以,
如果我使用它不会给出我正在使用的预期结果

这是我为使用而编写的代码

<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',


},}

Expected result: getting when using <Image>
Result using <ImageBackground>

最佳答案

您可以使用"ImageBackground" React Native 上的组件。

<ImageBackground
source={yourSourceFile}
style={{width: '100%', height: '100%'}}
>
<....yourContent...>
</ImageBackground>

关于javascript - 如何使用 ImageBackground 为 react-native 中的屏幕设置背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46886953/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com