Solve the problem of touch event not responding when Viewpager and ScrollView nested webview in MI system

Source: Internet
Author: User

Preface: always take the native android4.4 NEXUS5 test, the results loaded into the eldest brother Millet, out of the bug. Android compatibility problem really .... Difficult to describe.


Bug Detailed Description: I use webview run JS Goole map, alone use the webview when everything is normal, and when placed in ScrollView and Viewpager, Millet mobile phone will not be able to move the map, other mobile phone is no problem.


Solution:

First, ScrollView nested sets of WebView

As a novice, I simply checked the return values of the three functions of Viewpager and ScrollView (Dispatchtouchevent, Onintercepttouchevent, ontouchevent), There seems to be no difference between millet and other mobile phones.

After reading a post on the "touch event delivery mechanism" (portal http://www.xuebuyuan.com/610044.html), I tried the demo and finally found out where the problem was.

Xiaomi's ScrollView will mask the upper and lower gestures of all its sub-view, which will give the child View Motionevent.action_cancel event, which will cause subsequent motionevent events to be passed only to the ScrollView cutoff.

So I changed the return value of Onintercepttouchevent to false, and it's going to be weird here, as I said before, and here's the solution, I didn't go into it, The initial guess is that the millet system changed the Onintercepttouchevent function code of the native ScrollView, making the Motionevent event passed to the child view become motionevent.action_cancel.


Second, Viewpager nested sets of WebView

This thought solved the previous problem, the problem should be similar, the result is useless. Strangely, all touchevent-related functions of Viewpager and WebView are exactly the same as those printed on Xiaomi and other machines.

Well, take a closer look, or find a different, millet log more than one error: should nothappen:no rect-based-test nodes found.

After Baidu, refer to the http://blog.csdn.net/rambomatrix/article/details/22503077 solution.

The original is because Viewpager in the switch page, fragment in the WebView did not monitor themselves in the visible state. So, when you find that WebView should be visible, let it move and tell WebKit to prepare for the response.

Then use the code to let WebView a little bit up and down.

Solve the problem of touch event not responding when Viewpager and ScrollView nested webview in MI system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.