Css 在本机背景全屏显示时出现问题
我正在使用Expo iOS模拟器,一直在尝试使背景全屏显示,但无法正常工作Css 在本机背景全屏显示时出现问题,css,ios,reactjs,react-native,react-props,Css,Ios,Reactjs,React Native,React Props,我正在使用Expo iOS模拟器,一直在尝试使背景全屏显示,但无法正常工作 export default function App() { return ( <ScrollView > <View style={[styles.container]}> <Text style={styles.title}>Mt. Fuji</Text> <Image source=
export default function App() {
return (
<ScrollView >
<View style={[styles.container]}>
<Text style={styles.title}>Mt. Fuji</Text>
<Image source={require('./images/pic.jpeg')} style={styles.uriImg}/>
<TextImg imageUri={'https://m.media-amazon.com/images/M/MV5BZjRjOTFkOTktZWUzMi00YzMyLThkMmYtMjEwNmQyNzliYTNmXkEyXkFqcGdeQXVyNzQ1ODk3MTQ@._V1_.jpg'} text='Rick & Morty' style={[styles.text, styles.propImg]} />
<TextImg text='The Butterfly Nebula' imageUri={'https://www.dualdove.com/wp-content/uploads/2020/02/supernova-dying-star-in-the-shape-of-a-butterfly.jpg'} style={[styles.text, styles.propImg]} />
</View>
</ScrollView>
)
};
const styles = StyleSheet.create({
uriImg: {
width: 350,
height: 200,
top:110,
},
propImg: {
width: 350,
height: 200
},
container:{
backgroundColor: '#a1c5ff',
alignItems: 'center',
flex:1
});
导出默认函数App(){
返回(
富士山
)
};
const styles=StyleSheet.create({
乌里姆:{
宽度:350,
身高:200,
排名:110,
},
propImg:{
宽度:350,
身高:200
},
容器:{
背景颜色:“#a1c5ff”,
对齐项目:“居中”,
弹性:1
});
这就是它现在的样子
您可以从“react native”导入“维度”,如下所示:
import { Dimensions } from 'react-native';
现在,您可以通过以下方式获得屏幕宽度和高度:
const width = Dimensions.get('window').width;
const height = Dimensions.get('window').height;
定义这些值后,现在可以将容器宽度和高度设置为以下值:
container: {
width: width
height: height
}