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

RawScaleObserver

interface RawScaleObserver
androidx.ui.core.gesture.RawScaleObserver

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

Summary

Public methods

open Unit

Override to be notified when the scale has been cancelled.

open Float
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

open fun onScale(scaleFactor: Float): Float

Override to be notified when scaling has occurred.

When overridden, return the amount of scaling, expressed as a scale factor, that should be consumed. For example, if the scaleFactor is 1.5 and the client wants to consume all of the scaling, it should return 1.5. If it wants to consume none of the scaling, it should return 1.

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.
Return
The amount scaling that was actually used. This value should also be a scaleFactor that is in the range of S to 1, where S is the value of scaleFactor. (If you are scaling an image, just return the scaleFactor that the image actually scaled. For example, if scaleFactor is 2, and the image can only scale to 1.5, return 1.5). If you don't want bother with "nested scaling" (you simply want to consume all of the pointer movement related to scaling), just return the value of scaleFactor.

onStart

open fun onStart(): Unit

Override to be notified when scaling has started.

This will be called when scaling occurs (and when the associated RawScaleGestureDetector is allowed to start). 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 no pointers remain.

Only called after onStart and one or more calls to onScale