当前位置:网站首页>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 .
边栏推荐
- It's too difficult to use. Long articles plus pictures and texts will only be written in short articles in the future
- Deep understanding of C language pointer
- 一文详解图对比学习(GNN+CL)的一般流程和最新研究趋势
- 一次 Keepalived 高可用的事故,让我重学了一遍它
- Newton iterative method (solving nonlinear equations)
- Kotlin introductory notes (V) classes and objects, inheritance, constructors
- 22-07-04 Xi'an Shanghao housing project experience summary (01)
- Community group buying has triggered heated discussion. How does this model work?
- uni-app---uni. Navigateto jump parameter use
- [ManageEngine] how to make good use of the report function of OpManager
猜你喜欢
![[listening for an attribute in the array]](/img/1f/96eb85ee0af83d601918bcd04e405e.png)
[listening for an attribute in the array]

移动端异构运算技术-GPU OpenCL编程(进阶篇)

Applet customization component
![Multiple solutions to one problem, asp Net core application startup initialization n schemes [Part 1]](/img/c4/27ae0d259abc4e61286c1f4d90c06a.png)
Multiple solutions to one problem, asp Net core application startup initialization n schemes [Part 1]
![[ManageEngine] how to make good use of the report function of OpManager](/img/15/dc15e638ae86d6cf1d5b989fe56611.jpg)
[ManageEngine] how to make good use of the report function of OpManager

Node collaboration and publishing

顶会论文看图对比学习(GNN+CL)研究趋势

一文详解图对比学习(GNN+CL)的一般流程和最新研究趋势

C语言-从键盘输入数组二维数组a,将a中3×5矩阵中第3列的元素左移到第0列,第3列以后的每列元素行依次左移,原来左边的各列依次绕到右边

LeetCode 556. Next bigger element III
随机推荐
百度APP 基于Pipeline as Code的持续集成实践
Community group buying has triggered heated discussion. How does this model work?
Information and entropy, all you want to know is here
Applet customization component
2309. The best English letters with both upper and lower case
Svg optimization by svgo
The most comprehensive promotion strategy: online and offline promotion methods of E-commerce mall
Vs code problem: the length of long lines can be configured through "editor.maxtokenizationlinelength"
Using request headers to develop multi terminal applications
Wxss template syntax
Node の MongoDB Driver
移动端异构运算技术-GPU OpenCL编程(进阶篇)
LeetCode 556. 下一个更大元素 III
百度交易中台之钱包系统架构浅析
Kotlin introductory notes (I) kotlin variables and non variables
我的一生.
2311. Longest binary subsequence less than or equal to K
OpenGL - Lighting
Kotlin introductory notes (VIII) collection and traversal
Priority queue (heap)