当前位置:网站首页>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 .
边栏推荐
- 阿里云发送短信验证码
- mysql安装配置以及创建数据库和表
- [sourcetree configure SSH and use]
- 【sourceTree配置SSH及使用】
- Talking about label smoothing technology
- 植物大战僵尸Scratch
- An article takes you into the world of cookies, sessions, and tokens
- Kotlin introductory notes (IV) circular statements (simple explanation of while, for)
- [JS sort according to the attributes in the object array]
- OpenGL - Lighting
猜你喜欢
移动端异构运算技术-GPU OpenCL编程(进阶篇)
22-07-04 Xi'an Shanghao housing project experience summary (01)
Principle and performance analysis of lepton lossless compression
What are the advantages of the live teaching system to improve learning quickly?
Three-level distribution is becoming more and more popular. How should businesses choose the appropriate three-level distribution system?
c语言指针深入理解
How to choose the right chain management software?
Node の MongoDB Driver
How do enterprises choose the appropriate three-level distribution system?
Node の MongoDB Driver
随机推荐
【sourceTree配置SSH及使用】
微信小程序获取住户地区信息
How do enterprises choose the appropriate three-level distribution system?
代码语言的魅力
How to improve the operation efficiency of intra city distribution
The popularity of B2B2C continues to rise. What are the benefits of enterprises doing multi-user mall system?
A detailed explanation of the general process and the latest research trends of map comparative learning (gnn+cl)
How to choose the right chain management software?
Kotlin introductory notes (V) classes and objects, inheritance, constructors
基于模板配置的数据可视化平台
E-commerce apps are becoming more and more popular. What are the advantages of being an app?
Vs code problem: the length of long lines can be configured through "editor.maxtokenizationlinelength"
Uni app implements global variables
使用el-upload封装得组件怎么清空已上传附件
Node の MongoDB Driver
Node collaboration and publishing
Analysis of eventbus source code
It's too difficult to use. Long articles plus pictures and texts will only be written in short articles in the future
Unity SKFramework框架(二十三)、MiniMap 小地图工具
Hi Fun Summer, play SQL planner with starrocks!