【发布时间】:2020-12-15 02:26:28
【问题描述】:
我是 react native 的新手,我想使用 ImageBackground。
但是,当我尝试使用以下代码使其全屏显示时:
import React from 'react';
import { StyleSheet, ImageBackground,Text, View } from 'react-native';
const Signin = () => {
return (
<ImageBackground source={require('./images/background.jpg')} style={styles.image}>
<Text>Hello</Text>
</ImageBackground>
)
}
const styles = StyleSheet.create({
image: {
flex: 1,
width: '100%',
height: '100%',
resizeMode:'cover'
}
});
export default Signin;
它只返回我屏幕一半的图片。 关于它为什么这样做的任何想法?
我的初始图片可以在这里找到:https://unsplash.com/photos/0AwoTNSdwV
【问题讨论】:
-
这能回答你的问题吗? stackoverflow.com/questions/29322973/…
-
不幸的是,没有......我在发布我的问题之前查看了这个答案
标签: reactjs react-native imagebackground