Dela via


Scroller Class

Definition

This class encapsulates scrolling.

[Android.Runtime.Register("android/widget/Scroller", DoNotGenerateAcw=true)]
public class Scroller : Java.Lang.Object
[<Android.Runtime.Register("android/widget/Scroller", DoNotGenerateAcw=true)>]
type Scroller = class
    inherit Object
Inheritance
Scroller
Attributes

Remarks

This class encapsulates scrolling. You can use scrollers (Scroller or OverScroller) to collect the data you need to produce a scrolling animation&mdash;for example, in response to a fling gesture. Scrollers track scroll offsets for you over time, but they don't automatically apply those positions to your view. It's your responsibility to get and apply new coordinates at a rate that will make the scrolling animation look smooth.

Here is a simple example:

private Scroller mScroller = new Scroller(context);
            ...
            public void zoomIn() {
                // Revert any animation currently in progress
                mScroller.forceFinished(true);
                // Start scrolling by providing a starting point and
                // the distance to travel
                mScroller.startScroll(0, 0, 100, 0);
                // Invalidate to request a redraw
                invalidate();
            }

To track the changing positions of the x/y coordinates, use #computeScrollOffset. The method returns a boolean to indicate whether the scroller is finished. If it isn't, it means that a fling or programmatic pan operation is still in progress. You can use this method to find the current offsets of the x and y coordinates, for example:

if (mScroller.computeScrollOffset()) {
                // Get current x and y positions
                int currX = mScroller.getCurrX();
                int currY = mScroller.getCurrY();
               ...
            }

Java documentation for android.widget.Scroller.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

Scroller(Context, IInterpolator, Boolean)

Create a Scroller with the specified interpolator.

Scroller(Context, IInterpolator)

Create a Scroller with the specified interpolator.

Scroller(Context)

Create a Scroller with the default duration and interpolator.

Scroller(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
CurrVelocity

Returns the current velocity.

CurrX

Returns the current X offset in the scroll.

CurrY

Returns the current Y offset in the scroll.

Duration

Returns how long the scroll event will take, in milliseconds.

FinalX

Returns where the scroll will end. -or- Sets the final position (X) for this scroller.

FinalY

Returns where the scroll will end. -or- Sets the final position (Y) for this scroller.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsFinished

Returns whether the scroller has finished scrolling.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
StartX

Returns the start X offset in the scroll.

StartY

Returns the start Y offset in the scroll.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

AbortAnimation()

Stops the animation.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
ComputeScrollOffset()

Call this when you want to know the new location.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
ExtendDuration(Int32)

Extend the scroll animation.

Fling(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)

Start scrolling based on a fling gesture.

ForceFinished(Boolean)

Force the finished field to a particular value.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
SetFriction(Single)

The amount of friction applied to flings.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
StartScroll(Int32, Int32, Int32, Int32, Int32)

Start scrolling by providing a starting point, the distance to travel, and the duration of the scroll.

StartScroll(Int32, Int32, Int32, Int32)

Start scrolling by providing a starting point and the distance to travel.

TimePassed()

Returns the time elapsed since the beginning of the scrolling.

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to