当前位置:网站首页>Resolve the horizontal (vertical) sliding conflict between viewpager and WebView
Resolve the horizontal (vertical) sliding conflict between viewpager and WebView
2022-07-05 09:36:00 【Black Mountain demon 2018】
Rookies still talk about the problems encountered in the project .
Problem description :
Use... In projects viewpager + fragment To achieve multi-channel switching , One of them fragment There's a webview, This webview Loaded H5 page
There are left and right sliding carousels , Outer parent control (viewpager) Will intercept and consume left-right sliding events , therefore H5 You can't slide the left and right rotating pictures in .
Problem solving :
1. The first scheme is when the channel page is H5 When , Ban the outer layer viewpager Slide left and right , namely webview call requestDisallowInterceptTouchEvent(true) Don't let the parent layout intercept events . But this plan is too violent , If the product manager agrees .
2. The second scheme is native native And H5 Interact , from H5 tell native Location of its own rotation map , And then in webview Of onTouchListener Of onTouch Do the corresponding processing in the method , If the sliding gesture is in this range , be requestDisallowInterceptTouchEvent(true) Don't let the parent layout intercept events . conversely , Then let the parent layout intercept events . This scheme has many limitations , If H5 The need is clear , Just fixed in a certain area, there is a rotating broadcast that slides left and right , And the future will not change much , Then this plan is feasible , But if H5 The page has many controls that can slide left and right , And future demand is not necessarily , Then the scope of these controls must be told to the native . And the range judgment of the client will also follow H5 The changes of change follow the changes , In this case, it is not advisable . Specific reference https://www.jianshu.com/p/a6f9d4046985
3. The third scheme is also Native native And H5 Interact , Principle similarity . But it is different from scheme II ,H5 There is no need to tell native native The scope of specific rotation control , Native native You only need to define whether to let the parent layout intercept events for H5 Call .H5 The rotation control on only needs to be in the corresponding touchstart and touchmove Just adjust the original method . For details, please refer to https://www.jianshu.com/p/818d566c4c5a, I adopted this plan in the project .
边栏推荐
- 【两个对象合并成一个对象】
- SQL learning - case when then else
- 【阅读笔记】图对比学习 GNN+CL
- [sourcetree configure SSH and use]
- Go 语言使用 MySQL 的常见故障分析和应对方法
- Project practice | excel export function
- 顶会论文看图对比学习(GNN+CL)研究趋势
- 【PyTorch Bug】RuntimeError: Boolean value of Tensor with more than one value is ambiguous
- Dry goods sorting! How about the development trend of ERP in the manufacturing industry? It's enough to read this article
- 【饿了么动态表格】
猜你喜欢
c语言指针深入理解
Dry goods sorting! How about the development trend of ERP in the manufacturing industry? It's enough to read this article
The most comprehensive promotion strategy: online and offline promotion methods of E-commerce mall
百度智能小程序巡检调度方案演进之路
一文详解图对比学习(GNN+CL)的一般流程和最新研究趋势
【ManageEngine】如何利用好OpManager的报表功能
Community group buying exploded overnight. How should this new model of e-commerce operate?
MySQL installation configuration and creation of databases and tables
【阅读笔记】图对比学习 GNN+CL
Creation and reference of applet
随机推荐
MYSQL 对字符串类型排序不生效问题
基于STM32单片机的测温仪(带人脸检测)
Shutter uses overlay to realize global pop-up
C语言-从键盘输入数组二维数组a,将a中3×5矩阵中第3列的元素左移到第0列,第3列以后的每列元素行依次左移,原来左边的各列依次绕到右边
My life
An article takes you into the world of cookies, sessions, and tokens
High performance spark_ Transformation performance
Community group buying has triggered heated discussion. How does this model work?
Applet network data request
VS Code问题:长行的长度可通过 “editor.maxTokenizationLineLength“ 进行配置
Applet global style configuration window
【PyTorch Bug】RuntimeError: Boolean value of Tensor with more than one value is ambiguous
MySQL installation configuration and creation of databases and tables
[sourcetree configure SSH and use]
SMT32H7系列DMA和DMAMUX的一点理解
初识结构体
How to choose the right chain management software?
一文详解图对比学习(GNN+CL)的一般流程和最新研究趋势
[listening for an attribute in the array]
一篇文章带你走进cookie,session,Token的世界