# ViewConfigurationCompat

# ViewConfigurationCompat

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/view/ViewConfigurationCompat.java+class:androidx.core.view.ViewConfigurationCompat)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/view/ViewConfigurationCompat "View this page in Java")

<br />

```
class ViewConfigurationCompat
```

<br />

*** ** * ** ***

Helper for accessing features in[ViewConfiguration](https://developer.android.com/reference/android/view/ViewConfiguration.html).

## Summary

|                                       ### Public functions                                        |
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)     | [getScaledHorizontalScrollFactor](https://developer.android.com/reference/kotlin/androidx/core/view/ViewConfigurationCompat#getScaledHorizontalScrollFactor(android.view.ViewConfiguration,android.content.Context))`(` ` config: `[ViewConfiguration](https://developer.android.com/reference/android/view/ViewConfiguration.html)`,` ` context: `[Context](https://developer.android.com/reference/android/content/Context.html) `)`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `java-static `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)         | [getScaledHoverSlop](https://developer.android.com/reference/kotlin/androidx/core/view/ViewConfigurationCompat#getScaledHoverSlop(android.view.ViewConfiguration))`(config: `[ViewConfiguration](https://developer.android.com/reference/android/view/ViewConfiguration.html)`)`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `java-static `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)         | [getScaledMaximumFlingVelocity](https://developer.android.com/reference/kotlin/androidx/core/view/ViewConfigurationCompat#getScaledMaximumFlingVelocity(android.content.Context,android.view.ViewConfiguration,int,int,int))`(` ` context: `[Context](https://developer.android.com/reference/android/content/Context.html)`,` ` config: `[ViewConfiguration](https://developer.android.com/reference/android/view/ViewConfiguration.html)`,` ` inputDeviceId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` axis: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` source: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) `)` Maximum absolute value of velocity to initiate a fling for a motion generated by an[InputDevice](https://developer.android.com/reference/android/view/InputDevice.html)with an id of`inputDeviceId`, from an input`source`and on a given motion event`axis`. |
| `java-static `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)         | [getScaledMinimumFlingVelocity](https://developer.android.com/reference/kotlin/androidx/core/view/ViewConfigurationCompat#getScaledMinimumFlingVelocity(android.content.Context,android.view.ViewConfiguration,int,int,int))`(` ` context: `[Context](https://developer.android.com/reference/android/content/Context.html)`,` ` config: `[ViewConfiguration](https://developer.android.com/reference/android/view/ViewConfiguration.html)`,` ` inputDeviceId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` axis: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` source: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) `)` Minimum absolute value of velocity to initiate a fling for a motion generated by an[InputDevice](https://developer.android.com/reference/android/view/InputDevice.html)with an id of`inputDeviceId`, from an input`source`and on a given motion event`axis`. |
| `java-static `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)         | `@`[ReplaceWith](https://developer.android.com/reference/kotlin/androidx/annotation/ReplaceWith)`(expression = "config.getScaledPagingTouchSlop()")` ~~[getScaledPagingTouchSlop](https://developer.android.com/reference/kotlin/androidx/core/view/ViewConfigurationCompat#getScaledPagingTouchSlop(android.view.ViewConfiguration))~~`(config: `[ViewConfiguration](https://developer.android.com/reference/android/view/ViewConfiguration.html)`!)` **This function is deprecated.** Call[getScaledPagingTouchSlop](https://developer.android.com/reference/android/view/ViewConfiguration.html#getScaledPagingTouchSlop())directly. <br />                                                                                                                                                                                                                                                                                                                                                 |
| `java-static `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)     | [getScaledVerticalScrollFactor](https://developer.android.com/reference/kotlin/androidx/core/view/ViewConfigurationCompat#getScaledVerticalScrollFactor(android.view.ViewConfiguration,android.content.Context))`(` ` config: `[ViewConfiguration](https://developer.android.com/reference/android/view/ViewConfiguration.html)`,` ` context: `[Context](https://developer.android.com/reference/android/content/Context.html) `)`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `java-static `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `@`[ReplaceWith](https://developer.android.com/reference/kotlin/androidx/annotation/ReplaceWith)`(expression = "config.hasPermanentMenuKey()")` ~~[hasPermanentMenuKey](https://developer.android.com/reference/kotlin/androidx/core/view/ViewConfigurationCompat#hasPermanentMenuKey(android.view.ViewConfiguration))~~`(config: `[ViewConfiguration](https://developer.android.com/reference/android/view/ViewConfiguration.html)`!)` **This function is deprecated.** Use[hasPermanentMenuKey](https://developer.android.com/reference/android/view/ViewConfiguration.html#hasPermanentMenuKey())directly. <br />                                                                                                                                                                                                                                                                                                                                                                           |
| `java-static `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [shouldShowMenuShortcutsWhenKeyboardPresent](https://developer.android.com/reference/kotlin/androidx/core/view/ViewConfigurationCompat#shouldShowMenuShortcutsWhenKeyboardPresent(android.view.ViewConfiguration,android.content.Context))`(` ` config: `[ViewConfiguration](https://developer.android.com/reference/android/view/ViewConfiguration.html)`,` ` context: `[Context](https://developer.android.com/reference/android/content/Context.html) `)` Check if shortcuts should be displayed in menus.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |

## Public functions

### getScaledHorizontalScrollFactor

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
java-static fun getScaledHorizontalScrollFactor(
    config: ViewConfiguration,
    context: Context
): Float
```  

|                                                 Parameters                                                 |
|------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| `config: `[ViewConfiguration](https://developer.android.com/reference/android/view/ViewConfiguration.html) | Used to get the scaling factor directly from the[ViewConfiguration](https://developer.android.com/reference/android/view/ViewConfiguration.html). |
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)                 | Used to locate a resource value.                                                                                                                  |

|                                     Returns                                     |
|---------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | Amount to scroll in response to a horizontal[ACTION_SCROLL](https://developer.android.com/reference/kotlin/androidx/core/view/MotionEventCompat#ACTION_SCROLL())event. Multiply this by the event's axis value to obtain the number of pixels to be scrolled. |

### getScaledHoverSlop

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
java-static fun getScaledHoverSlop(config: ViewConfiguration): Int
```  

|                                                 Parameters                                                 |
|------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
| `config: `[ViewConfiguration](https://developer.android.com/reference/android/view/ViewConfiguration.html) | Used to get the hover slop directly from the[ViewConfiguration](https://developer.android.com/reference/android/view/ViewConfiguration.html). |

|                                   Returns                                   |
|-----------------------------------------------------------------------------|-----------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The hover slop value. |

### getScaledMaximumFlingVelocity

Added in[1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)  

```
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](https://developer.android.com/reference/android/view/InputDevice.html)with an id of`inputDeviceId`, from an input`source`and on a given motion event`axis`.

Similar to[getScaledMinimumFlingVelocity](https://developer.android.com/reference/kotlin/androidx/core/view/ViewConfigurationCompat#getScaledMinimumFlingVelocity(android.content.Context,android.view.ViewConfiguration,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[1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)  

```
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](https://developer.android.com/reference/android/view/InputDevice.html)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](https://developer.android.com/reference/android/view/MotionEvent.html#AXIS_SCROLL())vertical velocities generated from a[SOURCE_ROTARY_ENCODER](https://developer.android.com/reference/android/view/InputDevice.html#SOURCE_ROTARY_ENCODER()), the velocity returned from[VelocityTracker](https://developer.android.com/reference/android/view/VelocityTracker.html)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](https://developer.android.com/reference/android/view/MotionEvent.html#AXIS_SCROLL())velocity from the tracker is calculated in "units per second" (see[computeCurrentVelocity](https://developer.android.com/reference/android/view/VelocityTracker.html#computeCurrentVelocity(int)),[computeCurrentVelocity](https://developer.android.com/reference/android/view/VelocityTracker.html#computeCurrentVelocity(int, float))to adjust your velocity computations to "per second"), and use[getScaledVerticalScrollFactor](https://developer.android.com/reference/kotlin/androidx/core/view/ViewConfigurationCompat#getScaledVerticalScrollFactor(android.view.ViewConfiguration,android.content.Context))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](https://developer.android.com/reference/android/view/MotionEvent.html), use the device ID that is reported by the event, which can be obtained using[getDeviceId](https://developer.android.com/reference/android/view/MotionEvent.html#getDeviceId()). Otherwise, use a valid ID that is obtained from[getId](https://developer.android.com/reference/android/view/InputDevice.html#getId()), or from an[InputManager](https://developer.android.com/reference/android/hardware/input/InputManager.html)instance ([getInputDeviceIds](https://developer.android.com/reference/android/hardware/input/InputManager.html#getInputDeviceIds())gives all the valid input device IDs).

**axis** : a[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent.html)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](https://developer.android.com/reference/android/view/VelocityTracker.html)lets you calculate velocities for a specific axis. Use the axis for which you calculated velocity). You can use[getMotionRanges](https://developer.android.com/reference/android/view/InputDevice.html#getMotionRanges())to get all the[InputDevice.MotionRange](https://developer.android.com/reference/android/view/InputDevice.MotionRange.html)s for the[InputDevice](https://developer.android.com/reference/android/view/InputDevice.html), from which you can derive all the valid axes for the device.

**source** : use[getSource](https://developer.android.com/reference/android/view/MotionEvent.html#getSource())if calling this method in response to a[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent.html). Otherwise, use a valid source for the[InputDevice](https://developer.android.com/reference/android/view/InputDevice.html). You can use[getMotionRanges](https://developer.android.com/reference/android/view/InputDevice.html#getMotionRanges())to get all the[InputDevice.MotionRange](https://developer.android.com/reference/android/view/InputDevice.MotionRange.html)s for the[InputDevice](https://developer.android.com/reference/android/view/InputDevice.html), 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](https://developer.android.com/reference/android/content/Context.html)                 | the[Context](https://developer.android.com/reference/android/content/Context.html)associated with the view.                                                                                               |
| `config: `[ViewConfiguration](https://developer.android.com/reference/android/view/ViewConfiguration.html) | the[ViewConfiguration](https://developer.android.com/reference/android/view/ViewConfiguration.html)to derive the minimum fling velocity from.                                                             |
| `inputDeviceId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)               | the ID of the[InputDevice](https://developer.android.com/reference/android/view/InputDevice.html)that generated the motion triggering fling.                                                              |
| `axis: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                        | 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](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                      | the input source of the motion causing fling. This source should be a valid source for the[InputDevice](https://developer.android.com/reference/android/view/InputDevice.html)whose ID is`inputDeviceId`. |

|                                   Returns                                   |
|-----------------------------------------------------------------------------|-----------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the minimum velocity, in pixels/second, to trigger fling. |

|                                                        See also                                                        |
|------------------------------------------------------------------------------------------------------------------------|---|
| [getMotionRange](https://developer.android.com/reference/android/view/InputDevice.html#getMotionRange(int, int))       |   |
| [getMotionRanges](https://developer.android.com/reference/android/view/InputDevice.html#getMotionRanges())             |   |
| [getAxisVelocity](https://developer.android.com/reference/android/view/VelocityTracker.html#getAxisVelocity(int, int)) |   |
| [getAxisVelocity](https://developer.android.com/reference/android/view/VelocityTracker.html#getAxisVelocity(int))      |   |

### getScaledPagingTouchSlop

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  
Deprecated in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
@ReplaceWith(expression = "config.getScaledPagingTouchSlop()")
java-static fun [getScaledPagingTouchSlop](https://developer.android.com/reference/kotlin/androidx/core/view/ViewConfigurationCompat#getScaledPagingTouchSlop(android.view.ViewConfiguration))(config: ViewConfiguration!): Int
```
| **This function is deprecated.**   
|
| Call[getScaledPagingTouchSlop](https://developer.android.com/reference/android/view/ViewConfiguration.html#getScaledPagingTouchSlop())directly. This method will be removed in a future release.

Call[getScaledPagingTouchSlop](https://developer.android.com/reference/android/view/ViewConfiguration.html#getScaledPagingTouchSlop()).  

### getScaledVerticalScrollFactor

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
java-static fun getScaledVerticalScrollFactor(
    config: ViewConfiguration,
    context: Context
): Float
```  

|                                                 Parameters                                                 |
|------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| `config: `[ViewConfiguration](https://developer.android.com/reference/android/view/ViewConfiguration.html) | Used to get the scaling factor directly from the[ViewConfiguration](https://developer.android.com/reference/android/view/ViewConfiguration.html). |
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)                 | Used to locate a resource value.                                                                                                                  |

|                                     Returns                                     |
|---------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | Amount to scroll in response to a vertical[ACTION_SCROLL](https://developer.android.com/reference/kotlin/androidx/core/view/MotionEventCompat#ACTION_SCROLL())event. Multiply this by the event's axis value to obtain the number of pixels to be scrolled. |

### hasPermanentMenuKey

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  
Deprecated in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
@ReplaceWith(expression = "config.hasPermanentMenuKey()")
java-static fun [hasPermanentMenuKey](https://developer.android.com/reference/kotlin/androidx/core/view/ViewConfigurationCompat#hasPermanentMenuKey(android.view.ViewConfiguration))(config: ViewConfiguration!): Boolean
```
| **This function is deprecated.**   
|
| Use[hasPermanentMenuKey](https://developer.android.com/reference/android/view/ViewConfiguration.html#hasPermanentMenuKey())directly.

Report if the device has a permanent menu key available to the user, in a backwards compatible way.  

### shouldShowMenuShortcutsWhenKeyboardPresent

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
java-static fun shouldShowMenuShortcutsWhenKeyboardPresent(
    config: ViewConfiguration,
    context: Context
): Boolean
```

Check if shortcuts should be displayed in menus.  

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|--------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `True`if shortcuts should be displayed in menus. |