Android.view.VelocityTracker

Source: Internet
Author: User

As the name implies, rate tracker, mainly used to track the rate of touch events (flinging and getsture), is very useful in the design of UI effects.

When used:

Step1: Instantiated by the Velocitytracker.obtain () method.

Step2: Use Addmovement (motionevent) to specify the detection object.

Step3: The rate at which horizontal sliding is obtained by getxvelocity () (similar vertically).

The mastery of Velocitytracker is the use of several methods inside:

1. public static Velocitytracker obtain ()

Instantiating a Velocitytracker object

Note: Ensure that the Recycle () method is called after the monitoring is finished. Typically, only one active object is maintained to monitor the movement

2. public void Recycle ()

Retract Velocitytracker objects for reuse

Note: The object cannot be used again after this method is called

3. public void Clear ()

Set the rate tracker to the initial state

4. public void Addmovement (motionevent ev)

Add an action event to the tracker

Note: Typically used in Motionevent.action_down, motionevent.action_move, and motionevent.action_up conditions

EV is in, for example, in Ontouchevent (...) The Motionevent type parameter received in

5. public void computecurrentvelocity (int units)

Calculates the rate at which points are currently collected

Note: This method is expensive and prudent to use

6. Getxvelocity () and getxvelocity ()

To get the rate of horizontal and vertical

Note: use computecurrentvelocity (int) to set the rate of time unit

Summary: The use process is generally, instantiation-set monitoring events-set rate unit time-get the vertical to the velocity.

Statement: The article through the Web-based learning and query API Official document Summary, if there is an error place, WAN Wang message exchange.

Android.view.VelocityTracker

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.