用Icon和TouchableHighlight反应本机工具提示吗?

我正在使用[工具提示] [1],用户可以单击以获取说明。看起来像这样

<Tooltip popover={<Text>my explanation</Text>} backgroundColor={'rgb(255,179,16)'}>
   <Text>?</Text>
</Tooltip>

问题是用户需要单击确切的文本才能工作,我想在其周围创建一个不可见的框,以便用户可以单击其内部的任何位置以触发它。

<TouchableHighlight>
   <View style={{height: 48,alignSelf: 'stretch',justifyContent: 'center',backgroundColor: '#2196F3'}}>
     <Tooltip popover={<Text>my explanation</Text>} backgroundColor={'rgb(240,16)'}>
       <Text>?</Text>
     </Tooltip>
   </View>
</TouchableHighlight>

并且也尝试过

 <Tooltip popover={<Text>my explanation</Text>} backgroundColor={'rgb(240,16)'}>
     <Icon.Button name="help-circle"
         backgroundColor="##3b5998"
         borderColor="##3b5998"
         color="##3b5998">
     </Icon.Button>
 </Tooltip>

但是这两项均无用。任何人都可以建议我的代码出了什么问题以及如何解决。 另外,关于将来在需要可单击的内容时我该如何处理文本的任何建议,而且我希望将可单击的区域扩展到比文本本身更大的区域。

谢谢

hrbwyj 回答:用Icon和TouchableHighlight反应本机工具提示吗?

尝试一下

     <Tooltip popover={<Text>my explanation</Text>} backgroundColor={'rgb(240,179,16)'}>
      <View style={{ height: 48,alignSelf: 'stretch',justifyContent: 'center',backgroundColor: '#2196F3' }}>
        <Text>?</Text>
      </View>
    </Tooltip>

基本上,您必须将元素包装在工具提示中 还要查看View的hitslop属性,以增加可触摸的视图区域,这是通过高度和填充来增加可触摸区域的替代方法

本文链接:https://www.f2er.com/3114657.html

大家都在问