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
- Interface Scalegesturedetector.onscalegesturelistener a listener to receive notifications when a gesture occurs
- 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