ViewConfigurationCompat
class ViewConfigurationCompat
Helper for accessing features in ViewConfiguration.
Summary
Public functions |
|
|---|---|
java-static Float |
getScaledHorizontalScrollFactor( |
java-static Int |
getScaledHoverSlop(config: ViewConfiguration) |
java-static Int |
getScaledMaximumFlingVelocity(Maximum absolute value of velocity to initiate a fling for a motion generated by an |
java-static Int |
getScaledMinimumFlingVelocity(Minimum absolute value of velocity to initiate a fling for a motion generated by an |
java-static Int |
@ReplaceWith(expression = "config.getScaledPagingTouchSlop()")This function is deprecated. Call |
java-static Float |
getScaledVerticalScrollFactor( |
java-static Boolean |
@ReplaceWith(expression = "config.hasPermanentMenuKey()")This function is deprecated. Use |
java-static Boolean |
shouldShowMenuShortcutsWhenKeyboardPresent(Check if shortcuts should be displayed in menus. |
Public functions
getScaledHorizontalScrollFactor
java-static fun getScaledHorizontalScrollFactor(
config: ViewConfiguration,
context: Context
): Float
| Parameters | |
|---|---|
config: ViewConfiguration |
Used to get the scaling factor directly from the |
context: Context |
Used to locate a resource value. |
| Returns | |
|---|---|
Float |
Amount to scroll in response to a horizontal |
getScaledHoverSlop
java-static fun getScaledHoverSlop(config: ViewConfiguration): Int
| Parameters | |
|---|---|
config: ViewConfiguration |
Used to get the hover slop directly from the |
| Returns | |
|---|---|
Int |
The hover slop value. |
getScaledMaximumFlingVelocity
java-static fun getScaledMaximumFlingVelocity(
context: Context,
config: ViewConfiguration,
inputDeviceId: Int,
axis: Int,
source: Int
): Int
Maximum 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.
Similar to getScaledMinimumFlingVelocity, but for maximum fling velocity, instead of minimum. Also, unlike that method which returns Integer.MAX_VALUE for bad input device ID, source and/or motion event axis inputs, this method returns Integer.MIN_VALUE for such bad inputs.
getScaledMinimumFlingVelocity
java-static fun getScaledMinimumFlingVelocity(
context: Context,
config: ViewConfiguration,
inputDeviceId: Int,
axis: Int,
source: Int
): Int
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 AXIS_SCROLL vertical velocities generated from a 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 AXIS_SCROLL velocity from the tracker is calculated in "units per second" (see computeCurrentVelocity, computeCurrentVelocity 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.
Obtaining the correct arguments for this method call
inputDeviceId: if calling this method in response to a MotionEvent, use the device ID that is reported by the event, which can be obtained using getDeviceId. Otherwise, use a valid ID that is obtained from getId, or from an InputManager instance (getInputDeviceIds gives all the valid input device IDs).
axis: 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 getMotionRanges to get all the InputDevice.MotionRanges for the InputDevice, from which you can derive all the valid axes for the device.
source: use getSource if calling this method in response to a MotionEvent. Otherwise, use a valid source for the InputDevice. You can use 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.
| Parameters | |
|---|---|
context: Context |
the |
config: ViewConfiguration |
the |
inputDeviceId: Int |
the ID of the |
axis: Int |
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: Int |
the input source of the motion causing fling. This source should be a valid source for the |
| Returns | |
|---|---|
Int |
the minimum velocity, in pixels/second, to trigger fling. |
@ReplaceWith(expression = "config.getScaledPagingTouchSlop()")
java-static fungetScaledPagingTouchSlop(config: ViewConfiguration!): Int
Call getScaledPagingTouchSlop.
getScaledVerticalScrollFactor
java-static fun getScaledVerticalScrollFactor(
config: ViewConfiguration,
context: Context
): Float
| Parameters | |
|---|---|
config: ViewConfiguration |
Used to get the scaling factor directly from the |
context: Context |
Used to locate a resource value. |
| Returns | |
|---|---|
Float |
Amount to scroll in response to a vertical |
@ReplaceWith(expression = "config.hasPermanentMenuKey()")
java-static funhasPermanentMenuKey(config: ViewConfiguration!): Boolean
Report if the device has a permanent menu key available to the user, in a backwards compatible way.
shouldShowMenuShortcutsWhenKeyboardPresent
java-static fun shouldShowMenuShortcutsWhenKeyboardPresent(
config: ViewConfiguration,
context: Context
): Boolean
Check if shortcuts should be displayed in menus.
| Returns | |
|---|---|
Boolean |
|