Added in API level 1

ViewConfiguration

open class ViewConfiguration
kotlin.Any
   ↳ android.view.ViewConfiguration

Contains methods to standard constants used in the UI for timeouts, sizes, and distances.

Summary

Public constructors

Public methods
open static ViewConfiguration!
get(context: Context)

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
getScaledMaximumFlingVelocity(inputDeviceId: Int, axis: Int, source: 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
getScaledMinimumFlingVelocity(inputDeviceId: Int, axis: Int, source: 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

ViewConfiguration

Added in API level 1
ViewConfiguration()

Deprecated: Use android.view.ViewConfiguration#get(android.content.Context) instead.

Public methods

get

Added in API level 3
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.

Parameters
context Context: A visual Context used to initialize the view configuration. It must be Activity or other Context created with Context#createWindowContext(int, Bundle). This value cannot be null.

getAmbiguousGestureMultiplier

Added in API level 29
Deprecated in API level 30
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

Added in API level 23
open static fun getDefaultActionModeHideDuration(): Long
Return
Long the default duration in milliseconds for ActionMode#hide(long).

getDoubleTapTimeout

Added in API level 3
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

Added in API level 1
Deprecated in API level 15
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

Added in API level 1
Deprecated in API level 15
open static fun getFadingEdgeLength(): Int

Deprecated: Use getScaledFadingEdgeLength() instead.

Return
Int the length of the fading edges in dips

getGlobalActionKeyTimeout

Added in API level 1
Deprecated in API level 20
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

Added in API level 1
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

Added in API level 12
open static fun getKeyRepeatDelay(): Int
Return
Int the time between successive key repeats in milliseconds.

getKeyRepeatTimeout

Added in API level 12
open static fun getKeyRepeatTimeout(): Int
Return
Int the time before the first key repeat in milliseconds.

getLongPressTimeout

Added in API level 1
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

Added in API level 1
Deprecated in API level 15
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

Added in API level 4
Deprecated in API level 15
open static fun getMaximumFlingVelocity(): Int

Deprecated: Use getScaledMaximumFlingVelocity() instead.

Return
Int Maximum velocity to initiate a fling, as measured in dips per second.

getMinimumFlingVelocity

Added in API level 1
Deprecated in API level 15
open static fun getMinimumFlingVelocity(): Int

Deprecated: Use getScaledMinimumFlingVelocity() instead.

Return
Int Minimum velocity to initiate a fling, as measured in dips per second.

getMultiPressTimeout

Added in API level 31
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

Added in API level 1
open static fun getPressedStateDuration(): Int
Return
Int the duration in milliseconds of the pressed state in child components.

getScaledAmbiguousGestureMultiplier

Added in API level 30
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

Added in API level 3
open fun getScaledDoubleTapSlop(): Int
Return
Int Distance in pixels between the first touch and second touch to still be considered a double tap

getScaledEdgeSlop

Added in API level 3
open fun getScaledEdgeSlop(): Int
Return
Int Inset in pixels to look for touchable content when the user touches the edge of the screen

getScaledFadingEdgeLength

Added in API level 3
open fun getScaledFadingEdgeLength(): Int
Return
Int the length of the fading edges in pixels

getScaledHandwritingGestureLineMargin

Added in API level 34
open fun getScaledHandwritingGestureLineMargin(): Int
Return
Int margin in pixels around text line bounds where stylus handwriting gestures should be supported.

getScaledHandwritingSlop

Added in API level 34
open fun getScaledHandwritingSlop(): Int
Return
Int Distance in pixels a stylus touch can wander before we think the user is handwriting.

getScaledHorizontalScrollFactor

Added in API level 26
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

Added in API level 28
open fun getScaledHoverSlop(): Int
Return
Int Distance in pixels a hover can wander while it is still considered "stationary".

getScaledMaximumDrawingCacheSize

Added in API level 3
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

Added in API level 4
open fun getScaledMaximumFlingVelocity(): Int
Return
Int Maximum velocity to initiate a fling, as measured in pixels per second.

getScaledMaximumFlingVelocity

Added in API level 34
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

Added in API level 3
open fun getScaledMinimumFlingVelocity(): Int
Return
Int Minimum velocity to initiate a fling, as measured in pixels per second.

getScaledMinimumFlingVelocity

Added in API level 34
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.MotionRanges 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.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
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

Added in API level 29
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

Added in API level 9
open fun getScaledOverflingDistance(): Int
Return
Int The maximum distance a View should overfling by when showing edge effects (in pixels).

getScaledOverscrollDistance

Added in API level 9
open fun getScaledOverscrollDistance(): Int
Return
Int The maximum distance a View should overscroll by when showing edge effects (in pixels).

getScaledPagingTouchSlop

Added in API level 8
open fun getScaledPagingTouchSlop(): Int
Return
Int Distance in pixels a touch can wander before we think the user is scrolling a full page

getScaledScrollBarSize

Added in API level 3
open fun getScaledScrollBarSize(): Int
Return
Int The width of the horizontal scrollbar and the height of the vertical scrollbar in pixels

getScaledTouchSlop

Added in API level 3
open fun getScaledTouchSlop(): Int
Return
Int Distance in pixels a touch can wander before we think the user is scrolling

getScaledVerticalScrollFactor

Added in API level 26
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

Added in API level 3
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.

getScrollBarFadeDuration

Added in API level 5
open static fun getScrollBarFadeDuration(): Int
Return
Int Duration of the fade when scrollbars fade away in milliseconds

getScrollBarSize

Added in API level 1
Deprecated in API level 15
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

getScrollDefaultDelay

Added in API level 5
open static fun getScrollDefaultDelay(): Int
Return
Int Default delay before the scrollbars fade in milliseconds

getScrollFriction

Added in API level 1
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

Added in API level 1
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

Added in API level 1
Deprecated in API level 15
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

Added in API level 1
Deprecated in API level 15
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

Added in API level 1
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.

hasPermanentMenuKey

Added in API level 14
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.

shouldShowMenuShortcutsWhenKeyboardPresent

Added in API level 28
open fun shouldShowMenuShortcutsWhenKeyboardPresent(): Boolean

Check if shortcuts should be displayed in menus.

Return
Boolean True if shortcuts should be displayed in menus.