Css 反应本机-图像不会填充屏幕?
这令人沮丧。我有一个与屏幕(该设备)尺寸完全相同的图像,而且与飞溅图像尺寸相同。我只是想让它填充整个屏幕,在其他视图之上,在飞溅消失后几秒钟,以便制作自定义动画 看看其他的SO问题,我已经尝试过了(在其他应用程序元素的主容器之外):Css 反应本机-图像不会填充屏幕?,css,reactjs,react-native,Css,Reactjs,React Native,这令人沮丧。我有一个与屏幕(该设备)尺寸完全相同的图像,而且与飞溅图像尺寸相同。我只是想让它填充整个屏幕,在其他视图之上,在飞溅消失后几秒钟,以便制作自定义动画 看看其他的SO问题,我已经尝试过了(在其他应用程序元素的主容器之外): 飞溅:{ 弹性:1, 位置:'绝对', zIndex:4 }, 然而,图像被放大并远离角落。 这里有什么问题/我如何用图像填充屏幕?请使用react nativeImageBackground在背景中填充图像,请参考下面给出的示例代码 import React
飞溅:{
弹性:1,
位置:'绝对',
zIndex:4
},
然而,图像被放大并远离角落。
这里有什么问题/我如何用图像填充屏幕?请使用react native
ImageBackground
在背景中填充图像,请参考下面给出的示例代码
import React from "react";
import { ImageBackground, StyleSheet, Text, View } from "react-native";
const image = { uri: "https://reactjs.org/logo-og.png" };
const App = () => (
<View style={styles.container}>
<ImageBackground source={image} style={styles.image}>
<Text style={styles.text}>Inside</Text>
</ImageBackground>
</View>
);
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: "column"
},
image: {
flex: 1,
resizeMode: "cover",
justifyContent: "center"
},
text: {
color: "grey",
fontSize: 30,
fontWeight: "bold"
}
});
export default App;
从“React”导入React;
从“react native”导入{ImageBackground,StyleSheet,Text,View};
常量图像={uri:“https://reactjs.org/logo-og.png" };
常量应用=()=>(
在…内
);
const styles=StyleSheet.create({
容器:{
弹性:1,
flexDirection:“列”
},
图片:{
弹性:1,
resizeMode:“封面”,
为内容辩护:“中心”
},
正文:{
颜色:“灰色”,
尺寸:30,
fontWeight:“粗体”
}
});
导出默认应用程序;
在图像样式中使用样式表。absoluteFillObject
,而不是flex
它应该是像
import*as React from'React';
从“react native”导入{Image,View,StyleSheet,StatusBar};
导出默认函数App(){
返回(
);
}
const styles=StyleSheet.create({
容器:{
弹性:1,
对齐项目:“居中”,
为内容辩护:“中心”
},
图片:{
…StyleSheet.absoluteFillObject,
resizeMode:“封面”,
},
});
尝试使用。这是在根视图中吗?我需要将此图像与其他应用程序元素分开设置动画-因此它不能是其他元素的父元素;相反,它需要覆盖在顶部
import React from "react";
import { ImageBackground, StyleSheet, Text, View } from "react-native";
const image = { uri: "https://reactjs.org/logo-og.png" };
const App = () => (
<View style={styles.container}>
<ImageBackground source={image} style={styles.image}>
<Text style={styles.text}>Inside</Text>
</ImageBackground>
</View>
);
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: "column"
},
image: {
flex: 1,
resizeMode: "cover",
justifyContent: "center"
},
text: {
color: "grey",
fontSize: 30,
fontWeight: "bold"
}
});
export default App;