Android 当视图位于RN中的绝对位置时,触摸不可单击

Android 当视图位于RN中的绝对位置时,触摸不可单击,android,ios,react-native,Android,Ios,React Native,我试着保留几个按钮,一个在左上角,另一个在右边。但可触摸的动作不适用于右侧视图。 我想让两边都可以点击。但只有一方在起作用。 问题是什么 <View style={{flexDirection: 'row', justifyContent: 'space-between', justifyContent: 'center', paddingHorizontal: 12 }}> <View style={{flexDirection: 'row-reverse'}}>

我试着保留几个按钮,一个在左上角,另一个在右边。但可触摸的动作不适用于右侧视图。 我想让两边都可以点击。但只有一方在起作用。 问题是什么

<View style={{flexDirection: 'row', justifyContent: 'space-between', justifyContent: 'center', paddingHorizontal: 12 }}>
   <View style={{flexDirection: 'row-reverse'}}>
     <TouchableOpacity onPress={...}> Right icon 1 </TouchableOpacity>
     <TouchableOpacity onPress={...}> Right icon 2 </TouchableOpacity>
   </View>
   <TouchableOpacity onPress={...} style={{position: 'absolute', zIndex: 10}}> Back </TouchableOpacity>
</View>
可以使用alignSelf属性而不是绝对位置

<View
      style={{
        flexDirection: "row",
        paddingHorizontal: 12
      }}
    >
      <View style={{ flexDirection: "row-reverse",alignSelf:"flex-end" }}>
        <TouchableOpacity> Right icon 1 </TouchableOpacity>
        <TouchableOpacity> Right icon 2 </TouchableOpacity>
      </View>
      <TouchableOpacity style={{ alignSelf:"flex-start"}}> Back </TouchableOpacity>
</View>
注意更改:从容器中删除justifyContent,从back按钮中删除position&zIndex,并将alignSelf添加到两个孩子身上。

试试这个

    <View style={{ flexDirection: 'row', paddingHorizontal: 12 }}>
        <TouchableOpacity onPress={() => alert("back")} >
          <Text> Back </Text>
        </TouchableOpacity>
      <View style={{ flexDirection: 'row-reverse', flex: 2 }}>
        <TouchableOpacity onPress={() => alert("icon1")}>
          <Text>Right icon 1 </Text>
        </TouchableOpacity>
        <TouchableOpacity onPress={() => alert("icon2")}>
          <Text> Right icon 2</Text>
        </TouchableOpacity>
      </View>
    </View>

可能是位置:'absolute'和zIndex:10导致问题。此按钮可能与其他按钮重叠。你能检查一下吗?@Jaydepgalani是的。左边的按钮在上面重叠。若我尝试将右侧视图置于顶部,则左侧不可单击。除了给出静态位置值,还有什么更好的方法吗?所以你想让后退按钮在左边,其他按钮在右边?使用maxWidth、flex、width组合可以解决绝对元素的问题,或者你需要改变它的结构。我在我自己的用例中尝试了这个方法。我成功地将按钮正确对齐,但它带来了一些挑战,因为其余内容都依赖于它,但到最后,溢出仍然无法被读取。