Android Nested Scrolling

We have the main horizontal scroll view in our activity, and several vertical scrolls are displayed inside it. The idea is to scroll horizontally until you find the vertical list you want, then scroll up and down.

Ideally, I would like the vertical scroll bar to have a “lock” after starting the vertical scroll bar. What happens now, if you are very careful, you can scroll vertically, but if you move your finger too much left / right, doing this, vertical feet and horizontal ones capture.

That would probably make sense, no matter what type of scrolling is "activated" by your first movement, it remains active until you finish your interaction (that is, remove your finger).

Any way to make him act like that?

+6
source share
1 answer

It is better to use the ViewPager to scroll horizontally if it works for your application.

If this does not work, try overriding the onTouch method for vertical ScrollViews to prevent horizontal scrolling with

scrollView.setEnabled(false) 

Having ScrollViews nested inside other ScrollViews is usually bad practice, as it is usually more difficult for the user to navigate, so you may need to redesign this activity to avoid this problem.

If you should use nested ScrollViews, I found this two-dimensional ScrollView class that can help you.

+1
source

Source: https://habr.com/ru/post/895161/


All Articles