首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TouchableOpacity覆盖其他按钮

TouchableOpacity覆盖其他按钮
EN

Stack Overflow用户
提问于 2020-06-16 19:36:54
回答 1查看 172关注 0票数 0

在我的组件中,我为每个项目呈现了一个按钮。它起作用了。但是,当我将所有这些都包装在一个可触摸的TouchableOpacity中时,按钮就不再起作用了。现在一切都是可触摸的不透明。我怎么还能用这个按钮呢?

代码语言:javascript
复制
          return (
            <TouchableOpacity onPress= {()=> console.log('Hello')}>
            <View style={styles.item} key={item.id}>
              <Thumbnail
                style={styles.thumbnail}
                source={{
                  uri:
                    'https://cdn4.iconfinder.com/data/icons/avatars-xmas-giveaway/128/afro_woman_female_person-512.png',
                }}></Thumbnail>
                <View style={styles.nameNumber}>
              <Text style={styles.userName}>{userName}</Text>
              </View>
              <View style={styles.deleteButtonContainer}>
                <Button
                  rounded
                  style={styles.deleteButton}
                  onPress={() => onDeleteContact(item.id)}
                  >
                  <Icon name="trash-o" size={moderateScale(20)} color="black" />
                </Button>
              </View>
            </View>
            </TouchableOpacity>
          );
        },
EN

回答 1

Stack Overflow用户

发布于 2020-06-17 09:21:39

像这样改变吗?(除了按钮之外,是否要将标签换行?)

代码语言:javascript
复制
return (

    <View style={styles.item} key={item.id}>
      <TouchableOpacity onPress= {()=> console.log('Hello')}>
          <Thumbnail
            style={styles.thumbnail}
            source={{
              uri:
                'https://cdn4.iconfinder.com/data/icons/avatars-xmas-giveaway/128/afro_woman_female_person-512.png',
            }}></Thumbnail>
            <View style={styles.nameNumber}>
                <Text style={styles.userName}>{userName}</Text>
            </View>
      </TouchableOpacity>
      <View style={styles.deleteButtonContainer}>
        <Button
          rounded
          style={styles.deleteButton}
          onPress={() => onDeleteContact(item.id)}
          >
          <Icon name="trash-o" size={moderateScale(20)} color="black" />
        </Button>
      </View>
    </View>

  );
},
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62407546

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档