Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stop scrollView in the middle of the scroll

I have a scrollview with a lot of content. Now when user do a fling or scroll down, I want the scrollview to stop at a particular view location, where I am doing some animation, and then user can again fling or scroll down.

I have tried the disabling of scrollview as mentioned here but It only disables when the scrollview completely stops and cannot stop in the middle of a fling.

Is there any way I can stop a fling of the scrollview when a certain view location or a certain y value is reached?

like image 474
Deepak Senapati Avatar asked Jun 26 '13 04:06

Deepak Senapati


People also ask

How do I stop NestedScrollView scrolling?

setnestedscrollingenabled set it to false.

How do I turn off scroll view?

You cannot disable the scrolling of a ScrollView. You would need to extend to ScrollView and override the onTouchEvent method to return false when some condition is matched.

How do I stop ScrollView scrolling in Swift?

Basic Swift Code for iOS Apps For disabling the same we need to make the “isScrollEnabled” property of our scroll view to false. Copy the below code in your file. import UIKit class ViewController: UIViewController { @IBOutlet var scrollView: UIScrollView! override func viewDidLoad() { super.


2 Answers

I had the same problem my solution was.

listView.smoothScrollBy(0,0)

This will stop the scrolling.

like image 116
Yayo Arellano Avatar answered Sep 28 '22 08:09

Yayo Arellano


To stop a fling at a particular point simply call

fling(0)

If you are only concerned about flings this is the most logical way to do so in my opinion, because velosityYis set to 0 and thereby the fling is stopped immediately.

Here is the javadoc of the fling method:

/**
 * Fling the scroll view
 *
 * @param velocityY The initial velocity in the Y direction. Positive
 *                  numbers mean that the finger/cursor is moving down the screen,
 *                  which means we want to scroll towards the top.
 */
like image 29
Peter F Avatar answered Sep 28 '22 06:09

Peter F