Giter Site home page Giter Site logo

Comments (3)

bengelhaupt avatar bengelhaupt commented on September 22, 2024

So I had a look into this, fiddled around a bit and the problem is indeed the communication between ViewPager2 and NestedScrollWebView. How ViewPager swiping works, is by intercepting the touch events from its inner views and checking whether the user swiped sideways. Other scrollable views call requestDisallowInterceptTouchEvent(true) when they do not want parent views to intercept touch events. NestedScrollWebView does not do this and touch events are handled by the ViewPager. The NestedScrollWebView's custom scroll handling supports horizontal and vertical scrolling. So calling requestDisallowInterceptTouchEvent(true) on startNestedScroll() and requestDisallowInterceptTouchEvent(false) on stopNestedScroll() does completely disable ViewPager swiping.

The feature has been broken because ViewPager2 also allows a vertical orientation, while ViewPager(1) only supports horizontal. So I guess in ViewPager(1) only vertical scrolling was allowed in the pager tabs and therefore the NestedScrollWebView.
The documentation says: "ViewPager2 does not natively support nested scroll views in cases where the scroll view has the same orientation as the ViewPager2 object that contains it. [...] To support a scroll view inside a ViewPager2 object with the same orientation, you must call requestDisallowInterceptTouchEvent() on the ViewPager2 object when you expect to scroll the nested element instead."

Solutions are either disabling ViewPager swiping for the selected tab or only allowing to scroll the NestedScrollWebView vertically.

from xikolo-android.

tobiasrohloff avatar tobiasrohloff commented on September 22, 2024

Hmm, disabling ViewPager swiping only for certain tabs sounds wrong to me and very confusing for users. The drawback of only allowing to scroll the NestedScrollWebView vertically is that web pages with bad responsiveness cannot be scrolled horizontally anymore, right? The latter sounds okay-ish to me.

from xikolo-android.

bengelhaupt avatar bengelhaupt commented on September 22, 2024

Another idea would be to check whether there is "space to scroll" so pages that are already swiped to start allow viewpager swiping. But this would need a lot of custom touch handling.

from xikolo-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.