Android.widget.Scroller

Source: Internet
Author: User

I. Overview

This class encapsulates the scrolling operation. Use this class to get the data used to create a scrolling animation-for example, to respond to a swipe gesture.
Scroller tracks the scrolling offset (relative origin) at any time, but does not automatically apply these location information to our view.

Typically, the Computescrolleroffset () method is used to monitor the vertical and lateral deviations of the scroll, which returns a Boolean value that determines whether the scrolling animation is complete (true indicates that the animation has not been completed), which can be used to obtain an offset from the current position, such as

1 PrivateScroller Mscroller =NewScroller (context);2 3 4 if(Mscroller.computescrolloffset ()) {5      //get current horizontal and vertical position (relative origin (0,0))
6 intCurrx =Mscroller.getcurrx ();7 intCurrY =Mscroller.getcurry ();8 ...9}

Second, the structure function:
    Public Scroller (Context context)

Create a scroller with the default duration (250ms) and the animation insert

    Public Scroller (context context, interpolator interpolator)

Creates a scroller with a specific animation insert, using the default value if the corresponding parameter interpolator is empty

Iii. Public methods

1. public void Abortanimation ()

Aborts the animation. In contrast to Forcefinished (Boolean), stops the animation when scrolling to the end point coordinates.

    

2. Public boolean computescrolleroffset ()

Calculates the rolling offset. This method is called when you want to get new coordinate information, which is similar to the idea of computecurrentvelocity () in Android.view.VelocityTracker--calling a method to get the program to calculate, and then using other methods to get the results of the calculation. The difference is that scroller needs to determine if there is a scrolling action in progress, and a return value of TRUE indicates that the scroll is not completed (the current direction offset can be obtained), otherwise it is not possible to write related operations, such as the above code.

3. public void extendduration (int extend)

Extend the duration of the animation. When used with SETFINALX (int) and setfinaly (int), you can make the action last longer and slide longer. The parameter extend is in milliseconds.

It's time to sleep and not affect the rest of the roommate ...

Android.widget.Scroller

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.