“绝对”定位视图内的TouchableOpacity

时间:2019-10-28 15:01:47

标签: react-native z-index stylesheet absolute touchableopacity

我有以下看法

  <FlatList
      style={{marginTop: 5,
      position: 'absolute',
      top: 0,
      left: 0,
      right: 0,
      borderRadius: 5, backgroundColor: ACTIVITY_BACKGROUND_COLOR}}
      keyboardShouldPersistTaps={'always'}
      extraData={this.state.suggestions}
      listKey={(item, index)=>index.toString()}
      showsHorizontalScrollIndicator={false}
      horizontal={false}
      data={this.state.suggestions}
      keyExtractor={(index)=>index}
      renderItem={({item, index}) => {
           return (
                 <TouchableOpacity
                 onPress={()=>console.log('pressed')}
                 style={{paddingHorizontal: 10,
                 paddingTop: 5}}>
                       <Text
                       style={[styles.labelText, {
                              color: PRIMARY_COLOR,
                              marginVertical: 5,
                              backgroundColor:ACTIVITY_BACKGROUND_COLOR}]}>{item.description}</Text>
                       </TouchableOpacity>
                      );}}
     />

TouchableOpacityFlatlist中位于Android的“绝对”位置似乎无效。它如何在IOS上运行。我尝试添加zIndex,但所有其他操作均无效,并且TouchableOpacity不可点击。这种行为有什么原因吗?

0 个答案:

没有答案