ViewConfiguration
open class ViewConfiguration
Contains methods to standard constants used in the UI for timeouts, sizes, and distances.
Summary
Public methods |
open static ViewConfiguration! |
Returns a configuration for the specified visual Context .
|
open static Float |
The multiplication factor for inhibiting default gestures.
|
open static Long |
|
open static Int |
|
open static Int |
|
open static Int |
|
open static Long |
The amount of time a user needs to press the relevant key to bring up the global actions dialog.
|
open static Int |
|
open static Int |
|
open static Int |
|
open static Int |
Used for both key and motion events.
|
open static Int |
The maximum drawing cache size expressed in bytes.
|
open static Int |
|
open static Int |
|
open static Int |
|
open static Int |
|
open Float |
The multiplication factor for inhibiting default gestures.
|
open Int |
|
open Int |
|
open Int |
|
open Int |
|
open Int |
|
open Float |
|
open Int |
|
open Int |
The maximum drawing cache size expressed in bytes.
|
open Int |
|
open 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 .
|
open Int |
|
open 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 .
|
open Int |
Retrieves the distance in pixels between touches that must be reached for a gesture to be interpreted as scaling.
|
open Int |
|
open Int |
|
open Int |
|
open Int |
|
open Int |
|
open Float |
|
open Int |
|
open static Int |
|
open static Int |
|
open static Int |
|
open static Float |
The amount of friction applied to scrolls and flings.
|
open static Int |
|
open static Int |
|
open static Int |
|
open static Long |
The amount of time that the zoom controls should be displayed on the screen expressed in milliseconds.
|
open Boolean |
Report if the device has a permanent menu key available to the user.
|
open Boolean |
Check if shortcuts should be displayed in menus.
|
Public constructors
Public methods
get
open static fun get(context: Context): ViewConfiguration!
Returns a configuration for the specified visual Context
. The configuration depends on various parameters of the Context
, like the dimension of the display or the density of the display.
getAmbiguousGestureMultiplier
open static fun getAmbiguousGestureMultiplier(): Float
Deprecated: Use getScaledAmbiguousGestureMultiplier()
.
The multiplication factor for inhibiting default gestures. If a MotionEvent has android.view.MotionEvent#CLASSIFICATION_AMBIGUOUS_GESTURE
set, then certain actions, such as scrolling, will be inhibited. However, to account for the possibility of an incorrect classification, existing gesture thresholds (e.g. scrolling touch slop and the long-press timeout) should be scaled by this factor and remain in effect.
Return |
Float |
Value is 1.0 or greater |
getDefaultActionModeHideDuration
open static fun getDefaultActionModeHideDuration(): Long
getDoubleTapTimeout
open static fun getDoubleTapTimeout(): Int
Return |
Int |
the duration in milliseconds between the first tap's up event and the second tap's down event for an interaction to be considered a double-tap. |
getEdgeSlop
open static fun getEdgeSlop(): Int
Deprecated: Use getScaledEdgeSlop()
instead.
Return |
Int |
Inset in dips to look for touchable content when the user touches the edge of the screen |
getFadingEdgeLength
open static fun getFadingEdgeLength(): Int
Deprecated: Use getScaledFadingEdgeLength()
instead.
Return |
Int |
the length of the fading edges in dips |
getGlobalActionKeyTimeout
open static fun getGlobalActionKeyTimeout(): Long
Deprecated: This timeout should not be used by applications
The amount of time a user needs to press the relevant key to bring up the global actions dialog.
Return |
Long |
how long a user needs to press the relevant key to bring up the global actions dialog. |
getJumpTapTimeout
open static fun getJumpTapTimeout(): Int
Return |
Int |
the duration in milliseconds we will wait to see if a touch event is a jump tap. If the user does not move within this interval, it is considered to be a tap. |
getKeyRepeatDelay
open static fun getKeyRepeatDelay(): Int
Return |
Int |
the time between successive key repeats in milliseconds. |
getKeyRepeatTimeout
open static fun getKeyRepeatTimeout(): Int
Return |
Int |
the time before the first key repeat in milliseconds. |
getLongPressTimeout
open static fun getLongPressTimeout(): Int
Used for both key and motion events.
Return |
Int |
the duration in milliseconds before a press turns into a long press |
getMaximumDrawingCacheSize
open static fun getMaximumDrawingCacheSize(): Int
Deprecated: Use getScaledMaximumDrawingCacheSize()
instead.
The maximum drawing cache size expressed in bytes.
Return |
Int |
the maximum size of View's drawing cache expressed in bytes |
getMaximumFlingVelocity
open static fun getMaximumFlingVelocity(): Int
Deprecated: Use getScaledMaximumFlingVelocity()
instead.
Return |
Int |
Maximum velocity to initiate a fling, as measured in dips per second. |
getMinimumFlingVelocity
open static fun getMinimumFlingVelocity(): Int
Deprecated: Use getScaledMinimumFlingVelocity()
instead.
Return |
Int |
Minimum velocity to initiate a fling, as measured in dips per second. |
getMultiPressTimeout
open static fun getMultiPressTimeout(): Int
Return |
Int |
the duration in milliseconds between the first tap's up event and the second tap's down event for an interaction to be considered part of the same multi-press. |
getPressedStateDuration
open static fun getPressedStateDuration(): Int
Return |
Int |
the duration in milliseconds of the pressed state in child components. |
getScaledAmbiguousGestureMultiplier
open fun getScaledAmbiguousGestureMultiplier(): Float
The multiplication factor for inhibiting default gestures. If a MotionEvent has android.view.MotionEvent#CLASSIFICATION_AMBIGUOUS_GESTURE
set, then certain actions, such as scrolling, will be inhibited. However, to account for the possibility of an incorrect classification, existing gesture thresholds (e.g. scrolling touch slop and the long-press timeout) should be scaled by this factor and remain in effect.
Return |
Float |
Value is 1.0 or greater |
getScaledDoubleTapSlop
open fun getScaledDoubleTapSlop(): Int
Return |
Int |
Distance in pixels between the first touch and second touch to still be considered a double tap |
getScaledEdgeSlop
open fun getScaledEdgeSlop(): Int
Return |
Int |
Inset in pixels to look for touchable content when the user touches the edge of the screen |
getScaledFadingEdgeLength
open fun getScaledFadingEdgeLength(): Int
Return |
Int |
the length of the fading edges in pixels |
getScaledHandwritingGestureLineMargin
open fun getScaledHandwritingGestureLineMargin(): Int
Return |
Int |
margin in pixels around text line bounds where stylus handwriting gestures should be supported. |
getScaledHandwritingSlop
open fun getScaledHandwritingSlop(): Int
Return |
Int |
Distance in pixels a stylus touch can wander before we think the user is handwriting. |
open fun getScaledHorizontalScrollFactor(): Float
Return |
Float |
Amount to scroll in response to a horizontal MotionEvent.ACTION_SCROLL event. Multiply this by the event's axis value to obtain the number of pixels to be scrolled. |
getScaledHoverSlop
open fun getScaledHoverSlop(): Int
Return |
Int |
Distance in pixels a hover can wander while it is still considered "stationary". |
getScaledMaximumDrawingCacheSize
open fun getScaledMaximumDrawingCacheSize(): Int
The maximum drawing cache size expressed in bytes.
Return |
Int |
the maximum size of View's drawing cache expressed in bytes |
getScaledMaximumFlingVelocity
open fun getScaledMaximumFlingVelocity(): Int
Return |
Int |
Maximum velocity to initiate a fling, as measured in pixels per second. |
getScaledMaximumFlingVelocity
open fun getScaledMaximumFlingVelocity(
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(int,int,int)
, 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
open fun getScaledMinimumFlingVelocity(): Int
Return |
Int |
Minimum velocity to initiate a fling, as measured in pixels per second. |
getScaledMinimumFlingVelocity
open fun getScaledMinimumFlingVelocity(
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 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
.
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 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).
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 InputDevice.getMotionRanges()
to get all the InputDevice.MotionRange
s for the InputDevice
, from which you can derive all the valid axes for the device.
source: 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.MotionRange
s 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 |
inputDeviceId |
Int: the ID of the InputDevice that generated the motion triggering fling. |
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 InputDevice whose ID is inputDeviceId . |
Return |
Int |
the minimum velocity, in pixels/second, to trigger fling. |
getScaledMinimumScalingSpan
open fun getScaledMinimumScalingSpan(): Int
Retrieves the distance in pixels between touches that must be reached for a gesture to be interpreted as scaling. In general, scaling shouldn't start until this distance has been met or surpassed, and scaling should end when the distance in pixels between touches drops below this distance.
Return |
Int |
The distance in pixels |
Exceptions |
java.lang.IllegalStateException |
if this method is called on a ViewConfiguration that was instantiated using a constructor with no Context parameter. |
getScaledOverflingDistance
open fun getScaledOverflingDistance(): Int
Return |
Int |
The maximum distance a View should overfling by when showing edge effects (in pixels). |
open fun getScaledOverscrollDistance(): Int
Return |
Int |
The maximum distance a View should overscroll by when showing edge effects (in pixels). |
getScaledPagingTouchSlop
open fun getScaledPagingTouchSlop(): Int
Return |
Int |
Distance in pixels a touch can wander before we think the user is scrolling a full page |
open fun getScaledScrollBarSize(): Int
Return |
Int |
The width of the horizontal scrollbar and the height of the vertical scrollbar in pixels |
getScaledTouchSlop
open fun getScaledTouchSlop(): Int
Return |
Int |
Distance in pixels a touch can wander before we think the user is scrolling |
open fun getScaledVerticalScrollFactor(): Float
Return |
Float |
Amount to scroll in response to a vertical MotionEvent.ACTION_SCROLL event. Multiply this by the event's axis value to obtain the number of pixels to be scrolled. |
getScaledWindowTouchSlop
open fun getScaledWindowTouchSlop(): Int
Return |
Int |
Distance in pixels a touch must be outside the bounds of a window for it to be counted as outside the window for purposes of dismissing that window. |
open static fun getScrollBarFadeDuration(): Int
Return |
Int |
Duration of the fade when scrollbars fade away in milliseconds |
open static fun getScrollBarSize(): Int
Deprecated: Use getScaledScrollBarSize()
instead.
Return |
Int |
The width of the horizontal scrollbar and the height of the vertical scrollbar in dips |
open static fun getScrollDefaultDelay(): Int
Return |
Int |
Default delay before the scrollbars fade in milliseconds |
open static fun getScrollFriction(): Float
The amount of friction applied to scrolls and flings.
Return |
Float |
A scalar dimensionless value representing the coefficient of friction. |
getTapTimeout
open static fun getTapTimeout(): Int
Return |
Int |
the duration in milliseconds we will wait to see if a touch event is a tap or a scroll. If the user does not move within this interval, it is considered to be a tap. |
getTouchSlop
open static fun getTouchSlop(): Int
Deprecated: Use getScaledTouchSlop()
instead.
Return |
Int |
Distance in dips a touch can wander before we think the user is scrolling |
getWindowTouchSlop
open static fun getWindowTouchSlop(): Int
Deprecated: Use getScaledWindowTouchSlop()
instead.
Return |
Int |
Distance in dips a touch must be outside the bounds of a window for it to be counted as outside the window for purposes of dismissing that window. |
getZoomControlsTimeout
open static fun getZoomControlsTimeout(): Long
The amount of time that the zoom controls should be displayed on the screen expressed in milliseconds.
Return |
Long |
the time the zoom controls should be visible expressed in milliseconds. |
open fun hasPermanentMenuKey(): Boolean
Report if the device has a permanent menu key available to the user.
As of Android 3.0, devices may not have a permanent menu key available. Apps should use the action bar to present menu options to users. However, there are some apps where the action bar is inappropriate or undesirable. This method may be used to detect if a menu key is present. If not, applications should provide another on-screen affordance to access functionality.
Return |
Boolean |
true if a permanent menu key is present, false otherwise. |
open fun shouldShowMenuShortcutsWhenKeyboardPresent(): Boolean
Check if shortcuts should be displayed in menus.
Return |
Boolean |
True if shortcuts should be displayed in menus. |