Stay organized with collections
Save and categorize content based on your preferences.
OnScaleGestureListener
interface OnScaleGestureListener
The listener for receiving notifications when gestures occur. If you want to listen for all the different gestures then implement this interface. If you only want to listen for a subset it might be easier to extend SimpleOnScaleGestureListener
. An application will receive events in the following order:
Summary
Public methods |
abstract Boolean |
Responds to scaling events for a gesture in progress.
|
abstract Boolean |
Responds to the beginning of a scaling gesture.
|
abstract Unit |
Responds to the end of a scale gesture.
|
Public methods
onScale
abstract fun onScale(detector: ScaleGestureDetector): Boolean
Responds to scaling events for a gesture in progress. Reported by pointer motion.
Parameters |
detector |
ScaleGestureDetector: The detector reporting the event - use this to retrieve extended info about event state. This value cannot be null . |
Return |
Boolean |
Whether or not the detector should consider this event as handled. If an event was not handled, the detector will continue to accumulate movement until an event is handled. This can be useful if an application, for example, only wants to update scaling factors if the change is greater than 0.01. |
onScaleBegin
abstract fun onScaleBegin(detector: ScaleGestureDetector): Boolean
Responds to the beginning of a scaling gesture. Reported by new pointers going down.
Parameters |
detector |
ScaleGestureDetector: The detector reporting the event - use this to retrieve extended info about event state. This value cannot be null . |
Return |
Boolean |
Whether or not the detector should continue recognizing this gesture. For example, if a gesture is beginning with a focal point outside of a region where it makes sense, onScaleBegin() may return false to ignore the rest of the gesture. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# ScaleGestureDetector.OnScaleGestureListener\n\nAdded in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOnScaleGestureListener\n======================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/view/ScaleGestureDetector.OnScaleGestureListener \"View this page in Java\") \n\n```\ninterface OnScaleGestureListener\n```\n\n|---------------------------------------------------------------|\n| [android.view.ScaleGestureDetector.OnScaleGestureListener](#) |\n\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known Direct Subclasses [ScaleGestureDetector.SimpleOnScaleGestureListener](/reference/kotlin/android/view/ScaleGestureDetector.SimpleOnScaleGestureListener) |---------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------| | [ScaleGestureDetector.SimpleOnScaleGestureListener](/reference/kotlin/android/view/ScaleGestureDetector.SimpleOnScaleGestureListener) | A convenience class to extend when you only want to listen for a subset of scaling-related events. | |\n\nThe listener for receiving notifications when gestures occur. If you want to listen for all the different gestures then implement this interface. If you only want to listen for a subset it might be easier to extend [SimpleOnScaleGestureListener](/reference/kotlin/android/view/ScaleGestureDetector.SimpleOnScaleGestureListener). An application will receive events in the following order:\n\n- One [OnScaleGestureListener.onScaleBegin(ScaleGestureDetector)](#onScaleBegin(android.view.ScaleGestureDetector))\n- Zero or more [OnScaleGestureListener.onScale(ScaleGestureDetector)](#onScale(android.view.ScaleGestureDetector))\n- One [OnScaleGestureListener.onScaleEnd(ScaleGestureDetector)](#onScaleEnd(android.view.ScaleGestureDetector))\n\n\u003cbr /\u003e\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [onScale](#onScale(android.view.ScaleGestureDetector))`(`detector:` `[ScaleGestureDetector](/reference/kotlin/android/view/ScaleGestureDetector)`)` Responds to scaling events for a gesture in progress. |\n| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [onScaleBegin](#onScaleBegin(android.view.ScaleGestureDetector))`(`detector:` `[ScaleGestureDetector](/reference/kotlin/android/view/ScaleGestureDetector)`)` Responds to the beginning of a scaling gesture. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onScaleEnd](#onScaleEnd(android.view.ScaleGestureDetector))`(`detector:` `[ScaleGestureDetector](/reference/kotlin/android/view/ScaleGestureDetector)`)` Responds to the end of a scale gesture. |\n\nPublic methods\n--------------\n\n### onScale\n\nAdded in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onScale(detector: ScaleGestureDetector): Boolean\n```\n\nResponds to scaling events for a gesture in progress. Reported by pointer motion.\n\n| Parameters ||\n|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `detector` | [ScaleGestureDetector](/reference/kotlin/android/view/ScaleGestureDetector): The detector reporting the event - use this to retrieve extended info about event state. This value cannot be `null`. |\n\n| Return ||\n|------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | Whether or not the detector should consider this event as handled. If an event was not handled, the detector will continue to accumulate movement until an event is handled. This can be useful if an application, for example, only wants to update scaling factors if the change is greater than 0.01. |\n\n### onScaleBegin\n\nAdded in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onScaleBegin(detector: ScaleGestureDetector): Boolean\n```\n\nResponds to the beginning of a scaling gesture. Reported by new pointers going down.\n\n| Parameters ||\n|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `detector` | [ScaleGestureDetector](/reference/kotlin/android/view/ScaleGestureDetector): The detector reporting the event - use this to retrieve extended info about event state. This value cannot be `null`. |\n\n| Return ||\n|------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | Whether or not the detector should continue recognizing this gesture. For example, if a gesture is beginning with a focal point outside of a region where it makes sense, onScaleBegin() may return false to ignore the rest of the gesture. |\n\n### onScaleEnd\n\nAdded in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onScaleEnd(detector: ScaleGestureDetector): Unit\n```\n\nResponds to the end of a scale gesture. Reported by existing pointers going up. Once a scale has ended, [ScaleGestureDetector.getFocusX()](/reference/kotlin/android/view/ScaleGestureDetector#getFocusX()) and [ScaleGestureDetector.getFocusY()](/reference/kotlin/android/view/ScaleGestureDetector#getFocusY()) will return focal point of the pointers remaining on the screen.\n\n| Parameters ||\n|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `detector` | [ScaleGestureDetector](/reference/kotlin/android/view/ScaleGestureDetector): The detector reporting the event - use this to retrieve extended info about event state. This value cannot be `null`. |"]]