The second Android 11 Developer Preview is now available, test it out and share your feedback.

ScaleObserver

interface ScaleObserver
androidx.ui.core.gesture.ScaleObserver

Observes various events sent by ScaleGestureDetector. Implement and pass into ScaleGestureDetector so that ScaleGestureDetector may call the functions when events occur.

Summary

Public methods

open Unit

Override to be notified when the scale has been cancelled.

abstract Unit
onScale(scaleFactor: Float)

Override to be notified when scaling has occurred.

open Unit

Override to be notified when scaling has started.

open Unit

Override to be notified when scaling has stopped.

Public methods

onCancel

open fun onCancel(): Unit

Override to be notified when the scale has been cancelled.

This is called if onStart has ben called and then a cancellation event has occurs (for example, due to the gesture detector being removed from the tree) before onStop is called.

onScale

abstract fun onScale(scaleFactor: Float): Unit

Override to be notified when scaling has occurred.

Always called just after onStart (and for every subsequent scale).

Parameters
scaleFactor: Float The ratio of newSize / oldSize that the scaling gesture has expressed between pointers last position and current position (this value is not cumulative over the lifetime of of the gesture). For example, if 2 fingers are 10 pixel apart, and then move such that they are 20 pixels apart, the scaleFactor will be 2. If 2 fingers that are 20 pixels apart move such that they are 10 pixels apart, the scaleFactor will be .5.

onStart

open fun onStart(): Unit

Override to be notified when scaling has started.

This will be called when scaling occurs and a single pointer moves far enough to suggest the user intends to perform scaling (the required drag distance is defined by TouchSlop). Always called just before onScale and isn't called again until after onStop.

onStop

open fun onStop(): Unit

Override to be notified when scaling has stopped.

This is called once less than 2 pointers remain.

Only called after onStart and one or more calls to onScale