public class

ScaleGestureDetector

extends Object
java.lang.Object
   ↳ android.view.ScaleGestureDetector

Class Overview

Detects transformation gestures involving more than one pointer ("multitouch") using the supplied MotionEvents. The ScaleGestureDetector.OnScaleGestureListener callback will notify users when a particular gesture event has occurred. This class should only be used with MotionEvents reported via touch. To use this class:

Summary

Nested Classes
interface ScaleGestureDetector.OnScaleGestureListener The listener for receiving notifications when gestures occur. 
class ScaleGestureDetector.SimpleOnScaleGestureListener A convenience class to extend when you only want to listen for a subset of scaling-related events. 
Public Constructors
ScaleGestureDetector(Context context, ScaleGestureDetector.OnScaleGestureListener listener)
Public Methods
float getCurrentSpan()
Return the current distance between the two pointers forming the gesture in progress.
long getEventTime()
Return the event time of the current event being processed.
float getFocusX()
Get the X coordinate of the current gesture's focal point.
float getFocusY()
Get the Y coordinate of the current gesture's focal point.
float getPreviousSpan()
Return the previous distance between the two pointers forming the gesture in progress.
float getScaleFactor()
Return the scaling factor from the previous scale event to the current event.
long getTimeDelta()
Return the time difference in milliseconds between the previous accepted scaling event and the current scaling event.
boolean isInProgress()
Returns true if a two-finger scale gesture is in progress.
boolean onTouchEvent(MotionEvent event)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ScaleGestureDetector (Context context, ScaleGestureDetector.OnScaleGestureListener listener)

Since: API Level 8

Public Methods

public float getCurrentSpan ()

Since: API Level 8

Return the current distance between the two pointers forming the gesture in progress.

Returns
  • Distance between pointers in pixels.

public long getEventTime ()

Since: API Level 8

Return the event time of the current event being processed.

Returns
  • Current event time in milliseconds.

public float getFocusX ()

Since: API Level 8

Get the X coordinate of the current gesture's focal point. If a gesture is in progress, the focal point is directly between the two pointers forming the gesture. If a gesture is ending, the focal point is the location of the remaining pointer on the screen. If isInProgress() would return false, the result of this function is undefined.

Returns
  • X coordinate of the focal point in pixels.

public float getFocusY ()

Since: API Level 8

Get the Y coordinate of the current gesture's focal point. If a gesture is in progress, the focal point is directly between the two pointers forming the gesture. If a gesture is ending, the focal point is the location of the remaining pointer on the screen. If isInProgress() would return false, the result of this function is undefined.

Returns
  • Y coordinate of the focal point in pixels.

public float getPreviousSpan ()

Since: API Level 8

Return the previous distance between the two pointers forming the gesture in progress.

Returns
  • Previous distance between pointers in pixels.

public float getScaleFactor ()

Since: API Level 8

Return the scaling factor from the previous scale event to the current event. This value is defined as (getCurrentSpan() / getPreviousSpan()).

Returns
  • The current scaling factor.

public long getTimeDelta ()

Since: API Level 8

Return the time difference in milliseconds between the previous accepted scaling event and the current scaling event.

Returns
  • Time difference since the last scaling event in milliseconds.

public boolean isInProgress ()

Since: API Level 8

Returns true if a two-finger scale gesture is in progress.

Returns
  • true if a scale gesture is in progress, false otherwise.

public boolean onTouchEvent (MotionEvent event)

Since: API Level 8