我是React Native的新手,正在try 将<Image />
组件集中在更大的<View />
中,如下所示:
import { Image, View } from 'react-native';
<View
style={{
width: 48,
height: 48,
alignSelf: "center",
justifyContent: "center",
alignItems: "center",
position: "relative",
}}
>
<Image
style={{
width: 32,
height: 32,
position: "absolute",
top: 0,
left: 0,
right: 0,
bottom: 0,
margin: "auto",
}}
source={spinner}
/>
</View>;
但它不是居中,而是位于左上角<View />
以内.
上面的css可以在HTML中工作,但React Native我缺少什么?顺便说一句,我必须使用图像的绝对位置来覆盖<View />
内的其他组件.
谢谢,