ViewConfiguration.GetScaledMinimumFlingVelocity(Int32, Axis, Int32) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Minimum absolute value of velocity to initiate a fling for a motion generated by an
InputDevice with an id of inputDeviceId, from an input source and on
a given motion event axis.
[Android.Runtime.Register("getScaledMinimumFlingVelocity", "(III)I", "GetGetScaledMinimumFlingVelocity_IIIHandler", ApiSince=34)]
public virtual int GetScaledMinimumFlingVelocity(int inputDeviceId, Android.Views.Axis axis, int source);
[<Android.Runtime.Register("getScaledMinimumFlingVelocity", "(III)I", "GetGetScaledMinimumFlingVelocity_IIIHandler", ApiSince=34)>]
abstract member GetScaledMinimumFlingVelocity : int * Android.Views.Axis * int -> int
override this.GetScaledMinimumFlingVelocity : int * Android.Views.Axis * int -> int
Parameters
- inputDeviceId
- Int32
the ID of the InputDevice that generated the motion triggering
fling.
- axis
- Axis
the axis on which the motion triggering the fling happened. This axis should be a valid axis that can be reported by the provided input device from the provided input device source.
- source
- Int32
the input source of the motion causing fling. This source should be a valid
source for the InputDevice whose ID is inputDeviceId.
Returns
the minimum velocity, in pixels/second, to trigger fling.
- Attributes
Remarks
Minimum absolute value of velocity to initiate a fling for a motion generated by an InputDevice with an id of inputDeviceId, from an input source and on a given motion event axis.
Before utilizing this method to get a minimum fling velocity for a motion generated by the input device, scale the velocity of the motion events generated by the input device to pixels per second.
For instance, if you tracked MotionEvent#AXIS_SCROLL vertical velocities generated from a InputDevice#SOURCE_ROTARY_ENCODER, the velocity returned from VelocityTracker will be in the units with which the axis values were reported in the motion event. Before comparing that velocity against the minimum fling velocity specified here, make sure that the MotionEvent#AXIS_SCROLL velocity from the tracker is calculated in "units per second" (see VelocityTracker#computeCurrentVelocity(int), VelocityTracker#computeCurrentVelocity(int, float) to adjust your velocity computations to "per second"), and use #getScaledVerticalScrollFactor to change this velocity value to "pixels/second".
If the provided inputDeviceId is not valid, or if the input device whose ID is provided does not support the given motion event source and/or axis, this method will return Integer.MAX_VALUE.
<h3>Obtaining the correct arguments for this method call</h3>
<b>inputDeviceId</b>: if calling this method in response to a MotionEvent, use the device ID that is reported by the event, which can be obtained using MotionEvent#getDeviceId(). Otherwise, use a valid ID that is obtained from InputDevice#getId(), or from an InputManager instance (InputManager#getInputDeviceIds() gives all the valid input device IDs).
<b>axis</b>: a MotionEvent may report data for multiple axes, and each axis may have multiple data points for different pointers. Use the axis for which you obtained the velocity for (VelocityTracker lets you calculate velocities for a specific axis. Use the axis for which you calculated velocity). You can use InputDevice#getMotionRanges() to get all the InputDevice.MotionRanges for the InputDevice, from which you can derive all the valid axes for the device.
<b>source</b>: use MotionEvent#getSource() if calling this method in response to a MotionEvent. Otherwise, use a valid source for the InputDevice. You can use InputDevice#getMotionRanges() to get all the InputDevice.MotionRanges for the InputDevice, from which you can derive all the valid sources for the device.
This method optimizes calls over multiple input device IDs, so caching the return value of the method is not necessary if you are handling multiple input devices.
Java documentation for android.view.ViewConfiguration.getScaledMinimumFlingVelocity(int, int, int).
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.