Reputation: 4853
I've got the following Kotlin code:
val scrollView = parent as? NestedScrollView
scrollView?.let {
it.smoothScrollTo(0, 500)
}
The first time this code is called the scroll views scrollY is 0, and it successfully scrolls the view by 500 in the y. However, when this is called a second time it scrolls it another 500 (rather than scrolling it to 500 in the y, it will now be at 1000 and so on for consecutive calls.
Any idea what's going on here? When I drilled down into the code for NestedScrollView
(and eventually down into OverScroller's
startScroll
method that is ultimately called I can see the distance
parameter for that call on the y axis is 0 - as it should be for any other time than the first that my code is called).
EDIT: Important info - I tried with a ScrollView
rather than a NestedScrollView
and it worked as expected, however because my ScrollView
needs to be inside a SwipeRefreshLayout
I need it to be a NestedScrollView
else pulling down always refreshes rather than scrolling.
Upvotes: 1
Views: 725