React Native 如何将一个视图放在另一个视图之前
React Native How can I put one view in front of the other
我的 React Native 代码中有一个视图在另一个视图之前,我想更改它。
我该怎么做?
我试过放置绝对位置,但它不起作用。
有小费吗?
** 代码 JSX 波纹管:**
O 不知道我能告诉你什么,Stack OverFlow 不知道。
<PanGestureHandler
onGestureEvent={animatedEvent}
onHandlerStateChange={onHandlerStateChanged}>
<Animated.View
style={{
height: 90,
width: 90,
backgroundColor: '#8CC63F',
borderRadius: 50,
marginTop: 200,
transform: [
{
translateX: translateX.interpolate({
inputRange: [-120, 0, 120],
outputRange: [-100, 0, 120],
extrapolate: 'clamp',
}),
},
],
}}>
<View style={styles.iconContainer}>
<MaterialCommunityIcons
style={styles.iconContainer}
name="racing-helmet"
size={36}
color="#fff"
/>
</View>
</Animated.View>
</PanGestureHandler>
<View style={styles.iconsNavigation}>
<MaterialIcons
style={styles.iconSpace}
name="cancel"
size={30}
color="#707070"
/>
<MaterialIcons
style={styles.iconSpace}
name="check-circle"
size={30}
color="#8CC63F"
/>
</View>
</View>
样式代码如下:
iconContainer: {
justifyContent: 'center',
alignItems: 'center',
marginTop: 12,
},
iconsNavigation: {
flexDirection: 'row',
},
iconSpace: {
paddingHorizontal: 125,
bottom: 60,
},[![View in front of the other][1]][1]
j dd dddddddddd
ssxsxaaxxasxsassssssssssssssscsccdcdcdccdcdcdcdcddcddcddcdc
您可以使用 zIndex 来完成,例如:
<View id="top" style={{width: 100, height: 100, zIndex:2, backgroundColor: 'white'}} />
<View id="bottom" style={{width: 100, height: 100, zIndex:1, backgroundColor: 'black'}} />
通过运行,id="top" 的白色视图将位于最前面。现在您可以在您的代码中使用此 zIndex 样式 属性。
我的 React Native 代码中有一个视图在另一个视图之前,我想更改它。
我该怎么做?
我试过放置绝对位置,但它不起作用。
有小费吗?
** 代码 JSX 波纹管:**
O 不知道我能告诉你什么,Stack OverFlow 不知道。
<PanGestureHandler
onGestureEvent={animatedEvent}
onHandlerStateChange={onHandlerStateChanged}>
<Animated.View
style={{
height: 90,
width: 90,
backgroundColor: '#8CC63F',
borderRadius: 50,
marginTop: 200,
transform: [
{
translateX: translateX.interpolate({
inputRange: [-120, 0, 120],
outputRange: [-100, 0, 120],
extrapolate: 'clamp',
}),
},
],
}}>
<View style={styles.iconContainer}>
<MaterialCommunityIcons
style={styles.iconContainer}
name="racing-helmet"
size={36}
color="#fff"
/>
</View>
</Animated.View>
</PanGestureHandler>
<View style={styles.iconsNavigation}>
<MaterialIcons
style={styles.iconSpace}
name="cancel"
size={30}
color="#707070"
/>
<MaterialIcons
style={styles.iconSpace}
name="check-circle"
size={30}
color="#8CC63F"
/>
</View>
</View>
样式代码如下:
iconContainer: {
justifyContent: 'center',
alignItems: 'center',
marginTop: 12,
},
iconsNavigation: {
flexDirection: 'row',
},
iconSpace: {
paddingHorizontal: 125,
bottom: 60,
},[![View in front of the other][1]][1]
ssxsxaaxxasxsassssssssssssssscsccdcdcdccdcdcdcdcddcddcddcdc
您可以使用 zIndex 来完成,例如:
<View id="top" style={{width: 100, height: 100, zIndex:2, backgroundColor: 'white'}} />
<View id="bottom" style={{width: 100, height: 100, zIndex:1, backgroundColor: 'black'}} />
通过运行,id="top" 的白色视图将位于最前面。现在您可以在您的代码中使用此 zIndex 样式 属性。