Android 使重叠视图可触摸,以在react native中触发onPress
我有一个视图,它有重叠视图,根视图是绝对视图,而子视图是相对的,下面显示的按钮是相对的,按钮的上侧是可触摸的,但下侧没有黄色标记,因此不会触发onPress: 用于此操作的代码:Android 使重叠视图可触摸,以在react native中触发onPress,android,ios,react-native,Android,Ios,React Native,我有一个视图,它有重叠视图,根视图是绝对视图,而子视图是相对的,下面显示的按钮是相对的,按钮的上侧是可触摸的,但下侧没有黄色标记,因此不会触发onPress: 用于此操作的代码: render() { return ( <Card elevation={4}> <Card.Cover resizeMode="contain" source={{ uri: "https://en
render() {
return (
<Card elevation={4}>
<Card.Cover
resizeMode="contain"
source={{
uri:
"https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcTRDxz5NrZ1gdQOqyodN9Qudpw9Z2HTMsfzBm-D1vURyNQdJtNFJ6OLbS_wTlwr15b36BSDddr9&usqp=CAc",
}}
></Card.Cover>
<Card.Content>
<Title>Maverick Drone</Title>
</Card.Content>
<View
style={{
flex: 1,
position: "absolute",
bottom: "-8%",
right: 0,
flexDirection: "row",
}}
>
<View
style={{
elevation: 6,
shadowOffset: 0.8,
position: "relative",
justifyContent: "center",
alignItems: "center",
backgroundColor: "red",
width: 45,
height: 45,
borderRadius: 80,
}}
>
<TouchableRipple
borderless
rippleColor={Colors.purple600}
style={{ justifyContent: "center", alignItems: "center" }}
onPress={this.onDecrement}
>
<MatIcon color="white" size={32} name="minus"></MatIcon>
</TouchableRipple>
</View>
<View style={{ padding: 8 }}></View>
<View
style={{
elevation: 6,
shadowOffset: 0.8,
justifyContent: "center",
alignItems: "center",
borderRadius: 20,
backgroundColor: "darkred",
width: 60,
}}
>
<Text style={{ fontSize: 18, fontWeight: "bold", color: "white" }}>
{this.state.quantity}
</Text>
</View>
<View style={{ padding: 8 }}></View>
<View
style={{
elevation: 6,
shadowOffset: 0.8,
position: "relative",
justifyContent: "center",
alignItems: "center",
backgroundColor: "red",
width: 45,
height: 45,
borderRadius: 80,
}}
>
<TouchableRipple
borderless
rippleColor={Colors.purple600}
style={{ justifyContent: "center", alignItems: "center" }}
onPress={this.onIncrement}
>
<MatIcon color="white" size={32} name="plus"></MatIcon>
</TouchableRipple>
</View>
</View>
</Card>
);
}
render(){
返回(
特立独行的无人机
{this.state.quantity}
);
}
我在网上看到,这是react native的一个问题,它不支持重叠视图。
在react native中,可以采取哪些措施来避免此类问题或bug