react-native - 如何在 React Native 中仅接受对视图某些区域的触摸?
问题描述
我有这个视图层次结构:
<View style={{ flex: 1 }}>
<View ... />
<View style={{
position: "absolute",
bottom: 0,
right: 0,
width: Dimensions.get("screen").width,
height: Dimensions.get("screen").height,
backgroundColor: 'rgba(52, 52, 52, 0)'
}}
pointerEvents='none'
>
<WebView
pointerEvents='none'
style={{ flex: 1, backgroundColor: 'rgba(52, 52, 52, 0)' }}
source={require("source/assets/tawkto.html")}
/>
</View>
</View >
我的 html 由 1 个小部件元素和一个透明背景组成。显示 html 的 WebView 位于我的层次结构中每个视图的顶部。所以我的问题是是否可以仅在小部件区域(例如我知道的固定矩形区域)上接受触摸。通过使用pointerEvents
我实现了视图根本不接受触摸。
解决方案
尝试添加<View pointerEvents={'none'} />
您希望禁用触摸的视图
推荐阅读
- git - 如何在获取冒号后删除自动完成文本?
- java - 如何读取和发送用 Message.writeto() 编写的 java 邮件消息?
- performance - 停止应用程序的所有内存访问
- reactjs - 目录 react-app 包含可能发生冲突的文件:package.json
- javascript - 如何使用 JavaScript 动态调整 SVG 中文本元素的高度和宽度
- python - 在熊猫中合并2个xlsx文件
- node.js - 如何在 Windows 上更新 npm、节点版本?
- c# - 在 VSTS Web 测试循环中添加延迟/等待时间
- android - 迁移到 androidx 后无法解决 mutidex 问题
- typescript - 是否可以让 Knockout 无容器控制流语法在 Typescript 中工作?Typescript 正在剥离 HTML 中的注释绑定