You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native中TouchableOpacity添加zIndex后Android端无法触发点击问题求助

React Native中TouchableOpacity添加zIndex后Android端无法触发点击问题求助

大家好,我在React Native里写了一个自定义组件,结构是把TouchableOpacity嵌套在View里面,给外层View设置了zIndex: 10,TouchableOpacity用了绝对定位样式。现在遇到个头疼的问题:iOS设备上点击这个按钮完全正常,但Android端怎么点都没反应,实在找不到问题出在哪,麻烦各位帮忙看看!

以下是我的组件代码:

export function AaMobileSwap({onPress = () => {}}) {
  return (
    <View
      style={{
        zIndex: 10,
        justifyContent: 'center',
      }}>
      <TouchableOpacity
        activeOpacity={0.6}
        onPress={onPress}
        style={{
          position: 'absolute',
          marginLeft: -15.5,
        }}>
        <Icon
          name={"arrow_bidirection_arrow"}
          size={32}
          color={"808080"}
        />
      </TouchableOpacity>
    </View>
  );
}

备注:内容来源于stack exchange,提问作者Shariq Ahmed -

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.23 15:42:29