Android_scalegesturedetector Multi-Touch

Source: Internet
Author: User

public class Scalegesturedetector extends Object
    • Java.lang.Object
      • Android.view.ScaleGestureDetector
class overview

Detects deformation gestures caused by multiple contacts (Multitouch), based on the received motionevent. The callback method Scalegesturedetector.onscalegesturelistener notifies the user when a specific gesture event occurs

。 This class can only be used in conjunction with the motionevent triggered by the Touch event. Using this class requires

    • Create a Scalegesturedetector instance for your View
    • Ensure that Ontouchevent (motionevent) is called in the Ontouchevent (motionevent) method
    • The former is the Ontouchevent method of the class, and the latter is the Ontouchevent method of the View. When an event occurs, the method defined in callback is called.

Scalegesturedetector is a new class for Android2.2, allowing views to detect and process gesture change information, including multi-touch, through the provided motionevents.

Inner class
    1. Interface Scalegesturedetector.onscalegesturelistener a listener to receive notifications when a gesture occurs
    2. Classscalegesturedetector.simpleonscalegesturelistener If you want to listen to only a subset of scaling events, you can inherit the class.
Public Construction Method Scalegesturedetector (context context, Scalegesturedetector.onscalegesturelistener listener)

Common method Public float Getcurrentspan ()

Returns the current distance of the two contacts that make up the gesture during a gesture.

Return value: The contact distance in pixels.


Public long Geteventtime ()

Returns the time when the event was captured.

Returns the event time value in milliseconds.


public float Getfocusx ()

Returns the X-coordinate of the current gesture focus.

    • If the gesture is in progress, the focus is between the two contacts that make up the gesture.
    • If the gesture is ending, focus is on the position of the contact that remains on the screen.
    • If Isinprogress () returns FALSE, the return value of the method is undefined.

Return value: Returns the X-coordinate value of the focus, in pixels.


public float getfocusy ()

Returns the Y-coordinate of the current gesture focus.

    • If the gesture is in progress, the focus is between the two contacts that make up the gesture.
    • If the gesture is ending, focus is on the position of the contact that remains on the screen.
    • If Isinprogress () returns FALSE, the return value of the method is undefined.

The return value returns the Y-coordinate value of the focus, in pixels.


public float Getpreviousspan () returns the two contacts that make up the gesture during a gesture.Previous Distance。

Returns the previous distance, in pixels, of a value of two points.


public float Getscalefactor () returns the previous scaling event to the current scaling event.Scaling Ratio。 The value is defined as (Getcurrentspan ()/Getpreviousspan ()).

Returns the current scaling ratio of the value.


Public long Gettimedelta () returns the scaling events received from the previous one to the current scaling event.Time Difference, in milliseconds.

Returns the time difference, in milliseconds, from the start of the previous scaling event.


public boolean isinprogress () ifgesture is in progress, which returns True.

Returns the value if the gesture is in progress and returns TRUE. Otherwise, false is returned.


Android_scalegesturedetector Multi-Touch

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.