dragontrio.blogg.se

Smoothscroll vs scroll android
Smoothscroll vs scroll android




smoothscroll vs scroll android

On the left, the RV should not begin scrolling until the card has reached the top of the screen. The cause of both problems is that the RV is consuming scroll and fling events when it shouldn’t be. Figure 4 shows the two problematic bugs that I needed to fix. Unfortunately, simply using a NSV and RV was not enough to get the scrolling behavior I wanted. The RV returns true from the current call to onTouchEvent(ACTION_MOVE), consuming the touch event.The NSV’s onNestedScroll() method is called, giving the NSV an opportunity to consume any remaining scroll pixels that have still not been consumed.The RV calls its own dispatchNestedScroll() method, which notifies the NSV that it has consumed a portion of the scroll.The RV consumes the remainder of the scroll (or does nothing if the NSV consumed the entire event).The NSV’s onNestedPreScroll() method is called, giving the NSV an opportunity to react to the scroll event before the RV consumes it.The RV calls its own dispatchNestedPreScroll() method, which notifies the NSV that it is about to consume a portion of the scroll.The RV’s onTouchEvent(ACTION_MOVE) method is called.This becomes clear when you consider the sequence of events that takes place when the user drags their finger on top of the RV: If the NSV is not at the bottom of its content, scrolling the RV down should cause the NSV to scroll down.Īs you might expect, the nested scrolling APIs provide a way for the NSV and RV to communicate with each other throughout the duration of the scroll, so that each view can confidently determine who should consume each scroll event.If the RV is at the top of its content, scrolling the RV up should cause the NSV to scroll up.What we really want is to create the illusion that the two views are scrolling together as a single unit.

smoothscroll vs scroll android

Without nested scrolling, the RV will immediately consume the scroll event, resulting in the undesirable behavior we saw in Figure 2. Let’s say the user attempts to scroll the RV above. Figure 3 - The sample app consists of a parent NestedScrollView and a child RecyclerView.






Smoothscroll vs scroll android