当前位置:网站首页>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 .
边栏推荐
- 【组队 PK 赛】本周任务已开启 | 答题挑战,夯实商品详情知识
- Can't find the activitymainbinding class? The pit I stepped on when I just learned databinding
- Unity SKFramework框架(二十二)、Runtime Console 运行时调试工具
- Android 隐私沙盒开发者预览版 3: 隐私安全和个性化体验全都要
- 一文详解图对比学习(GNN+CL)的一般流程和最新研究趋势
- c语言指针深入理解
- 一次 Keepalived 高可用的事故,让我重学了一遍它
- 测试老鸟浅谈unittest和pytest的区别
- SQL learning - case when then else
- 百度评论中台的设计与探索
猜你喜欢

Community group buying has triggered heated discussion. How does this model work?

Kotlin introductory notes (II) a brief introduction to kotlin functions

NIPS2021 | 超越GraphCL,GNN+对比学习的节点分类新SOTA

Lepton 无损压缩原理及性能分析

Community group buying exploded overnight. How should this new model of e-commerce operate?

c语言指针深入理解

What are the advantages of the live teaching system to improve learning quickly?

C language - input array two-dimensional array a from the keyboard, and put 3 in a × 5. The elements in the third column of the matrix are moved to the left to the 0 column, and the element rows in ea

Principle and performance analysis of lepton lossless compression

初识结构体
随机推荐
Creation and reference of applet
移动端异构运算技术-GPU OpenCL编程(进阶篇)
图神经网络+对比学习,下一步去哪?
Unity skframework framework (XXII), runtime console runtime debugging tool
Applet global style configuration window
Using request headers to develop multi terminal applications
STM32简易多级菜单(数组查表法)
植物大战僵尸Scratch
[ManageEngine] how to make good use of the report function of OpManager
Progressive JPEG pictures and related
Kotlin introductory notes (I) kotlin variables and non variables
Can't find the activitymainbinding class? The pit I stepped on when I just learned databinding
[how to disable El table]
VS Code问题:长行的长度可通过 “editor.maxTokenizationLineLength“ 进行配置
OpenGL - Model Loading
What about wechat mall? 5 tips to clear your mind
测试老鸟浅谈unittest和pytest的区别
基于模板配置的数据可视化平台
OpenGL - Coordinate Systems
Multiple solutions to one problem, asp Net core application startup initialization n schemes [Part 1]