ViewCompat

open class ViewCompat
kotlin.Any
   ↳ androidx.core.view.ViewCompat

Helper for accessing features in View.

Summary

Nested classes

abstract

Interface definition for a callback to be invoked when a hardware key event hasn't been handled by the view hierarchy.

Constants

static Int

Live region mode specifying that accessibility services should interrupt ongoing speech to immediately announce changes to this view.

static Int

Live region mode specifying that accessibility services should not automatically announce changes to this view.

static Int

Live region mode specifying that accessibility services should announce changes to this view.

static Int

Automatically determine whether a view is important for accessibility.

static Int

The view is not important for accessibility.

static Int

The view is not important for accessibility, nor are any of its descendant views.

static Int

The view is important for accessibility.

static Int

Indicates that the view has a hardware layer.

static Int

Indicates that the view does not have a layer.

static Int

Indicates that the view has a software layer.

static Int

Horizontal layout direction of this view is inherited from its parent.

static Int

Horizontal layout direction of this view is from deduced from the default language script for the locale.

static Int

Horizontal layout direction of this view is from Left to Right.

static Int

Horizontal layout direction of this view is from Right to Left.

static Int

Bit shift of MEASURED_STATE_MASK to get to the height bits for functions that combine both width and height into a single int, such as getMeasuredState and the childState argument of resolveSizeAndState(int, int, int).

static Int

Bits of getMeasuredWidthAndState and getMeasuredWidthAndState that provide the actual measured size.

static Int

Bits of getMeasuredWidthAndState and getMeasuredWidthAndState that provide the additional state bits.

static Int

Bit of getMeasuredWidthAndState and getMeasuredWidthAndState that indicates the measured size is smaller that the space the view would like to have.

static Int

Always allow a user to over-scroll this view, provided it is a view that can scroll.

static Int

Allow a user to over-scroll this view only if the content is large enough to meaningfully scroll, provided it is a view that can scroll.

static Int

Never allow a user to over-scroll this view.

static Int

Indicates scrolling along the horizontal axis.

static Int

Indicates no axis of view scrolling.

static Int

Indicates scrolling along the vertical axis.

static Int

Scroll indicator direction for the bottom edge of the view.

static Int

Scroll indicator direction for the ending edge of the view.

static Int

Scroll indicator direction for the left edge of the view.

static Int

Scroll indicator direction for the right edge of the view.

static Int

Scroll indicator direction for the starting edge of the view.

static Int

Scroll indicator direction for the top edge of the view.

static Int

Indicates that the input type for the gesture is caused by something which is not a user touching a screen.

static Int

Indicates that the input type for the gesture is from a user touching the screen.

Protected constructors

Public methods

open static Int
addAccessibilityAction(@NonNull view: View, @NonNull label: CharSequence, @NonNull command: AccessibilityViewCommand)

Adds an accessibility action that can be performed on a node associated with a view.

open static Unit
addKeyboardNavigationClusters(@NonNull view: View, @NonNull views: MutableCollection<View!>, direction: Int)

Adds any keyboard navigation cluster roots that are descendants of view ( including view if it is a cluster root itself) to views.

open static Unit

Adds a listener which will receive unhandled KeyEvents.

open static ViewPropertyAnimatorCompat
animate(@NonNull view: View)

This method returns a ViewPropertyAnimator object, which can be used to animate specific properties on this View.

open static Boolean
canScrollHorizontally(view: View!, direction: Int)

Check if this view can be scrolled horizontally in a certain direction.

open static Boolean
canScrollVertically(view: View!, direction: Int)

Check if this view can be scrolled vertically in a certain direction.

open static Unit
cancelDragAndDrop(@NonNull v: View)

Cancel the drag and drop operation.

open static Int
combineMeasuredStates(curState: Int, newState: Int)

Merge two states as returned by getMeasuredState(View).

open static WindowInsetsCompat!

Request to apply the given window insets to this view or another view in its subtree.

open static Unit

Notify a view that its temporary detach has ended; the view is now reattached.

open static Boolean
dispatchNestedFling(@NonNull view: View, velocityX: Float, velocityY: Float, consumed: Boolean)

Dispatch a fling to a nested scrolling parent.

open static Boolean
dispatchNestedPreFling(@NonNull view: View, velocityX: Float, velocityY: Float)

Dispatch a fling to a nested scrolling parent before it is processed by this view.

open static Boolean
dispatchNestedPreScroll(@NonNull view: View, dx: Int, dy: Int, @Nullable consumed: IntArray?, @Nullable offsetInWindow: IntArray?)

Dispatch one step of a nested scroll in progress before this view consumes any portion of it.

open static Boolean
dispatchNestedPreScroll(@NonNull view: View, dx: Int, dy: Int, @Nullable consumed: IntArray?, @Nullable offsetInWindow: IntArray?, type: Int)

Dispatch one step of a nested scroll in progress before this view consumes any portion of it.

open static Boolean
dispatchNestedScroll(@NonNull view: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int, @Nullable offsetInWindow: IntArray?)

Dispatch one step of a nested scroll in progress.

open static Unit
dispatchNestedScroll(@NonNull view: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int, @Nullable offsetInWindow: IntArray?, type: Int, @NonNull consumed: IntArray)

Dispatch one step of a nested scroll in progress.

open static Boolean
dispatchNestedScroll(@NonNull view: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int, @Nullable offsetInWindow: IntArray?, type: Int)

Dispatch one step of a nested scroll in progress.

open static Unit

Notify a view that it is being temporarily detached.

open static Unit

Allow accessibility services to find and activate clickable spans in the application.

open static Int

Generate a value suitable for use in View#setId(int).

open static AccessibilityDelegateCompat?

Get the current accessibility delegate.

open static Int

Gets the live region mode for the specified View.

open static AccessibilityNodeProviderCompat!

Gets the provider for managing a virtual view hierarchy rooted at this View and reported to android.accessibilityservice.AccessibilityServices that explore the window content.

open static CharSequence!

Get the title of the pane for purposes of accessibility.

open static Float
getAlpha(view: View!)

The opacity of the view.

open static ColorStateList!
getBackgroundTintList(@NonNull view: View)

Return the tint applied to the background drawable, if specified.

open static Mode!
getBackgroundTintMode(@NonNull view: View)

Return the blending mode used to apply the tint to the background drawable, if specified.

open static Rect?
getClipBounds(@NonNull view: View)

Returns a copy of the current setClipBounds(View, Rect).

open static Display?
getDisplay(@NonNull view: View)

Gets the logical display to which the view's window has been attached.

open static Float
getElevation(@NonNull view: View)

The base elevation of this view relative to its parent, in pixels.

open static Boolean

Returns true if this view should adapt to fit system window insets.

open static Int

Gets the mode for determining whether this View is important for accessibility which is if it fires accessibility events and if it is reported to accessibility services that query the screen.

open static Int

Gets the mode for determining whether this view is important for autofill.

open static Int
getLabelFor(@NonNull view: View)

Gets the id of a view for which a given view serves as a label for accessibility purposes.

open static Int

Indicates what type of layer is currently associated with this view.

open static Int
getLayoutDirection(@NonNull view: View)

Returns the resolved layout direction for this view.

open static Matrix?
getMatrix(view: View!)

The transform matrix of this view, which is calculated based on the current rotation, scale, and pivot properties.

open static Int

Return the full height measurement information for this view as computed by the most recent call to android.view.View#measure(int, int).

open static Int

Return only the state bits of getMeasuredWidthAndState and getMeasuredHeightAndState, combined into one integer.

open static Int

Return the full width measurement information for this view as computed by the most recent call to android.view.View#measure(int, int).

open static Int
getMinimumHeight(@NonNull view: View)

Returns the minimum height of the view.

open static Int
getMinimumWidth(@NonNull view: View)

Returns the minimum width of the view.

open static Int
getNextClusterForwardId(@NonNull view: View)

Gets the ID of the next keyboard navigation cluster root.

open static Int

Returns the over-scroll mode for this view.

open static Int
getPaddingEnd(@NonNull view: View)

Returns the end padding of the specified view depending on its resolved layout direction.

open static Int
getPaddingStart(@NonNull view: View)

Returns the start padding of the specified view depending on its resolved layout direction.

open static ViewParent!

Gets the parent for accessibility purposes.

open static Float
getPivotX(view: View!)

The x location of the point around which the view is rotated and scaled.

open static Float
getPivotY(view: View!)

The y location of the point around which the view is rotated and scaled.

open static Float
getRotation(view: View!)

open static Float

open static Float

open static Float
getScaleX(view: View!)

open static Float
getScaleY(view: View!)

open static Int
getScrollIndicators(@NonNull view: View)

Returns a bitmask representing the enabled scroll indicators.

open static MutableList<Rect!>

Retrieve the list of areas within this view's post-layout coordinate space where the system should not intercept touch or other pointing device gestures.

open static String?
getTransitionName(@NonNull view: View)

Returns the name of the View to be used to identify Views in Transitions.

open static Float

The horizontal location of this view relative to its left position.

open static Float

The vertical location of this view relative to its top position.

open static Float
getTranslationZ(@NonNull view: View)

The depth location of this view relative to its elevation.

open static Int

Returns the current system UI visibility that is currently set for the entire window.

open static Float
getX(view: View!)

open static Float
getY(view: View!)

open static Float
getZ(@NonNull view: View)

The visual z position of this view, in pixels.

open static Boolean

Checks whether provided View has an accessibility delegate attached to it.

open static Boolean
hasExplicitFocusable(@NonNull view: View)

Returns true if this view is focusable or if it contains a reachable View for which View#hasExplicitFocusable() returns true.

open static Boolean

Returns true if this view has a nested scrolling parent.

open static Boolean
hasNestedScrollingParent(@NonNull view: View, type: Int)

Returns true if this view has a nested scrolling parent.

open static Boolean
hasOnClickListeners(@NonNull view: View)

Returns whether the provided view has an attached View.OnClickListener.

open static Boolean
hasOverlappingRendering(@NonNull view: View)

Returns whether this View has content which overlaps.

open static Boolean
hasTransientState(@NonNull view: View)

Indicates whether the view is currently tracking transient state that the app should not need to concern itself with saving and restoring, but that the framework should take special note to preserve when possible.

open static Boolean

Gets whether this view is a heading for accessibility purposes.

open static Boolean
isAttachedToWindow(@NonNull view: View)

Returns true if the provided view is currently attached to a window.

open static Boolean
isFocusedByDefault(@NonNull view: View)

Returns whether view should receive focus when the focus is restored for the view hierarchy containing it.

open static Boolean

Computes whether this view should be exposed for accessibility.

open static Boolean

Hints the Android System whether the android.app.assist.AssistStructure.ViewNode associated with this view is considered important for autofill purposes.

open static Boolean
isInLayout(@NonNull view: View)

Returns whether the view hierarchy is currently undergoing a layout pass.

open static Boolean

Returns whether view is a root of a keyboard navigation cluster.

open static Boolean
isLaidOut(@NonNull view: View)

Returns true if view has been through at least one layout since it was last attached to or detached from a window.

open static Boolean

Returns whether layout direction has been resolved.

open static Boolean

Returns true if nested scrolling is enabled for this view.

open static Boolean
isOpaque(view: View!)

Indicates whether this View is opaque.

open static Boolean
isPaddingRelative(@NonNull view: View)

Return if the padding as been set through relative values View.setPaddingRelative(int, int, int, int) or thru

open static Boolean

Returns whether the view should be treated as a focusable unit by screen reader accessibility tools.

open static Unit

On API 11 devices and above, call Drawable.jumpToCurrentState() on all Drawable objects associated with this view.

open static View!
keyboardNavigationClusterSearch(@NonNull view: View, currentCluster: View!, direction: Int)

Find the nearest keyboard navigation cluster in the specified direction.

open static Unit
offsetLeftAndRight(@NonNull view: View, offset: Int)

Offset this view's horizontal location by the specified amount of pixels.

open static Unit
offsetTopAndBottom(@NonNull view: View, offset: Int)

Offset this view's vertical location by the specified number of pixels.

open static WindowInsetsCompat!
onApplyWindowInsets(@NonNull view: View, insets: WindowInsetsCompat!)

Called when the view should apply WindowInsetsCompat according to its internal policy.

open static Unit

Initializes an AccessibilityEvent with information about this View which is the event source.

open static Unit

Initializes an AccessibilityNodeInfoCompat with information about this view.

open static Unit

Called from View#dispatchPopulateAccessibilityEvent(AccessibilityEvent) giving a chance to this View to populate the accessibility event with its text content.

open static Boolean
performAccessibilityAction(@NonNull view: View, action: Int, arguments: Bundle!)

Performs the specified accessibility action on the view.

open static Unit

Cause an invalidate to happen on the next animation time step, typically the next display frame.

open static Unit
postInvalidateOnAnimation(@NonNull view: View, left: Int, top: Int, right: Int, bottom: Int)

Cause an invalidate of the specified area to happen on the next animation time step, typically the next display frame.

open static Unit
postOnAnimation(@NonNull view: View, action: Runnable!)

Causes the Runnable to execute on the next animation time step.

open static Unit
postOnAnimationDelayed(@NonNull view: View, action: Runnable!, delayMillis: Long)

Causes the Runnable to execute on the next animation time step, after the specified amount of time elapses.

open static Unit
removeAccessibilityAction(@NonNull view: View, actionId: Int)

Removes an accessibility action that can be performed on a node associated with a view.

open static Unit

Removes a listener which will receive unhandled KeyEvents.

open static Unit
replaceAccessibilityAction(@NonNull view: View, @NonNull replacedAction: AccessibilityNodeInfoCompat.AccessibilityActionCompat, @Nullable label: CharSequence?, @Nullable command: AccessibilityViewCommand?)

Replaces an action.

open static Unit
requestApplyInsets(@NonNull view: View)

Ask that a new dispatch of View.onApplyWindowInsets(WindowInsets) be performed.

open static T
requireViewById(@NonNull view: View, @IdRes id: Int)

Finds the first descendant view with the given ID, the view itself if the ID matches View#getId(), or throws an IllegalArgumentException if the ID is invalid or there is no matching view in the hierarchy.

open static Int
resolveSizeAndState(size: Int, measureSpec: Int, childMeasuredState: Int)

Utility to reconcile a desired size and state, with constraints imposed by a MeasureSpec.

open static Boolean
restoreDefaultFocus(@NonNull view: View)

Gives focus to the default-focus view in the view hierarchy rooted at view.

open static Unit

Sets a delegate for implementing accessibility support via composition (as opposed to inheritance).

open static Unit
setAccessibilityHeading(view: View!, isHeading: Boolean)

Set if view is a heading for a section of content for accessibility purposes.

open static Unit
setAccessibilityLiveRegion(@NonNull view: View, mode: Int)

Sets the live region mode for the specified view.

open static Unit
setAccessibilityPaneTitle(view: View!, accessibilityPaneTitle: CharSequence!)

Visually distinct portion of a window with window-like semantics are considered panes for accessibility purposes.

open static Unit
setActivated(view: View!, activated: Boolean)

Changes the activated state of this view.

open static Unit
setAlpha(view: View!, value: Float)

Sets the opacity of the view.

open static Unit
setAutofillHints(@NonNull v: View, @Nullable vararg autofillHints: String!)

Sets the hints that help an android.service.autofill.AutofillService determine how to autofill the view with the user's data.

open static Unit
setBackground(@NonNull view: View, @Nullable background: Drawable?)

Set the background of the view to a given Drawable, or remove the background.

open static Unit
setBackgroundTintList(@NonNull view: View, tintList: ColorStateList!)

Applies a tint to the background drawable.

open static Unit
setBackgroundTintMode(@NonNull view: View, mode: Mode!)

Specifies the blending mode used to apply the tint specified by setBackgroundTintList(android.view.View, android.content.res.ColorStateList) to the background drawable.

open static Unit

Tells the ViewGroup whether to draw its children in the order defined by the method ViewGroup.getChildDrawingOrder(int, int).

open static Unit
setClipBounds(@NonNull view: View, clipBounds: Rect!)

Sets a rectangular area on this view to which the view will be clipped when it is drawn.

open static Unit
setElevation(@NonNull view: View, elevation: Float)

Sets the base elevation of this view, in pixels.

open static Unit
setFitsSystemWindows(view: View!, fitSystemWindows: Boolean)

Sets whether or not this view should account for system screen decorations such as the status bar and inset its content; that is, controlling whether the default implementation of View#fitSystemWindows(Rect) will be executed.

open static Unit
setFocusedByDefault(@NonNull view: View, isFocusedByDefault: Boolean)

Sets whether view should receive focus when the focus is restored for the view hierarchy containing it.

open static Unit
setHasTransientState(@NonNull view: View, hasTransientState: Boolean)

Set whether this view is currently tracking transient state that the framework should attempt to preserve when possible.

open static Unit
setImportantForAccessibility(@NonNull view: View, mode: Int)

Sets how to determine whether this view is important for accessibility which is if it fires accessibility events and if it is reported to accessibility services that query the screen.

open static Unit
setImportantForAutofill(@NonNull v: View, mode: Int)

Sets the mode for determining whether this view is considered important for autofill.

open static Unit
setKeyboardNavigationCluster(@NonNull view: View, isCluster: Boolean)

Set whether view is a root of a keyboard navigation cluster.

open static Unit
setLabelFor(@NonNull view: View, @IdRes labeledId: Int)

Sets the id of a view for which a given view serves as a label for accessibility purposes.

open static Unit
setLayerPaint(@NonNull view: View, paint: Paint!)

Updates the Paint object used with the current layer (used only if the current layer type is not set to View#LAYER_TYPE_NONE).

open static Unit
setLayerType(view: View!, layerType: Int, paint: Paint!)

Specifies the type of layer backing this view.

open static Unit
setLayoutDirection(@NonNull view: View, layoutDirection: Int)

Set the layout direction for this view.

open static Unit
setNestedScrollingEnabled(@NonNull view: View, enabled: Boolean)

Enable or disable nested scrolling for this view.

open static Unit
setNextClusterForwardId(@NonNull view: View, nextClusterForwardId: Int)

Sets the ID of the next keyboard navigation cluster root view.

open static Unit

Set an OnApplyWindowInsetsListener to take over the policy for applying window insets to this view.

open static Unit
setOverScrollMode(v: View!, overScrollMode: Int)

Set the over-scroll mode for this view.

open static Unit
setPaddingRelative(@NonNull view: View, @Px start: Int, @Px top: Int, @Px end: Int, @Px bottom: Int)

Sets the relative padding.

open static Unit
setPivotX(view: View!, value: Float)

Sets the x location of the point around which the view is rotated and scaled.

open static Unit
setPivotY(view: View!, value: Float)

Sets the y location of the point around which the view is rotated and scaled.

open static Unit
setPointerIcon(@NonNull view: View, pointerIcon: PointerIconCompat!)

Set the pointer icon for the current view.

open static Unit
setRotation(view: View!, value: Float)

Sets the degrees that the view is rotated around the pivot point.

open static Unit
setRotationX(view: View!, value: Float)

Sets the degrees that the view is rotated around the horizontal axis through the pivot point.

open static Unit
setRotationY(view: View!, value: Float)

Sets the degrees that the view is rotated around the vertical axis through the pivot point.

open static Unit

Controls whether the entire hierarchy under this view will save its state when a state saving traversal occurs from its parent.

open static Unit
setScaleX(view: View!, value: Float)

Sets the amount that the view is scaled in x around the pivot point, as a proportion of the view's unscaled width.

open static Unit
setScaleY(view: View!, value: Float)

Sets the amount that the view is scaled in Y around the pivot point, as a proportion of the view's unscaled width.

open static Unit
setScreenReaderFocusable(view: View!, screenReaderFocusable: Boolean)

Sets whether this View should be a focusable element for screen readers and include non-focusable Views from its subtree when providing feedback.

open static Unit
setScrollIndicators(@NonNull view: View, indicators: Int)

Sets the state of all scroll indicators.

open static Unit
setScrollIndicators(@NonNull view: View, indicators: Int, mask: Int)

Sets the state of the scroll indicators specified by the mask.

open static Unit
setSystemGestureExclusionRects(@NonNull view: View, @NonNull rects: MutableList<Rect!>)

Sets a list of areas within this view's post-layout coordinate space where the system should not intercept touch or other pointing device gestures.

open static Unit
setTooltipText(@NonNull view: View, @Nullable tooltipText: CharSequence?)

Sets the tooltip for the view.

open static Unit
setTransitionName(@NonNull view: View, transitionName: String!)

Sets the name of the View to be used to identify Views in Transitions.

open static Unit
setTranslationX(view: View!, value: Float)

Sets the horizontal location of this view relative to its left position.

open static Unit
setTranslationY(view: View!, value: Float)

Sets the vertical location of this view relative to its top position.

open static Unit
setTranslationZ(@NonNull view: View, translationZ: Float)

Sets the depth location of this view relative to its elevation.

open static Unit
setX(view: View!, value: Float)

Sets the visual x position of this view, in pixels.

open static Unit
setY(view: View!, value: Float)

Sets the visual y position of this view, in pixels.

open static Unit
setZ(@NonNull view: View, z: Float)

Sets the visual z position of this view, in pixels.

open static Boolean
startDragAndDrop(@NonNull v: View, data: ClipData!, shadowBuilder: DragShadowBuilder!, localState: Any!, flags: Int)

Start the drag and drop operation.

open static Boolean
startNestedScroll(@NonNull view: View, axes: Int)

Begin a nestable scroll operation along the given axes.

open static Boolean
startNestedScroll(@NonNull view: View, axes: Int, type: Int)

Begin a nestable scroll operation along the given axes.

open static Unit
stopNestedScroll(@NonNull view: View)

Stop a nested scroll in progress.

open static Unit
stopNestedScroll(@NonNull view: View, type: Int)

Stop a nested scroll in progress.

open static Unit
updateDragShadow(@NonNull v: View, shadowBuilder: DragShadowBuilder!)

Update the drag shadow while drag and drop is in progress.

Constants

ACCESSIBILITY_LIVE_REGION_ASSERTIVE

static val ACCESSIBILITY_LIVE_REGION_ASSERTIVE: Int

Live region mode specifying that accessibility services should interrupt ongoing speech to immediately announce changes to this view.

Use with ViewCompat#setAccessibilityLiveRegion(View, int).

Value: 0x00000002

ACCESSIBILITY_LIVE_REGION_NONE

static val ACCESSIBILITY_LIVE_REGION_NONE: Int

Live region mode specifying that accessibility services should not automatically announce changes to this view. This is the default live region mode for most views.

Use with ViewCompat#setAccessibilityLiveRegion(View, int).

Value: 0x00000000

ACCESSIBILITY_LIVE_REGION_POLITE

static val ACCESSIBILITY_LIVE_REGION_POLITE: Int

Live region mode specifying that accessibility services should announce changes to this view.

Use with ViewCompat#setAccessibilityLiveRegion(View, int).

Value: 0x00000001

IMPORTANT_FOR_ACCESSIBILITY_AUTO

static val IMPORTANT_FOR_ACCESSIBILITY_AUTO: Int

Automatically determine whether a view is important for accessibility.

Value: 0x00000000

IMPORTANT_FOR_ACCESSIBILITY_NO

static val IMPORTANT_FOR_ACCESSIBILITY_NO: Int

The view is not important for accessibility.

Value: 0x00000002

IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS

static val IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS: Int

The view is not important for accessibility, nor are any of its descendant views.

Value: 0x00000004

IMPORTANT_FOR_ACCESSIBILITY_YES

static val IMPORTANT_FOR_ACCESSIBILITY_YES: Int

The view is important for accessibility.

Value: 0x00000001

LAYER_TYPE_HARDWARE

static val LAYER_TYPE_HARDWARE: Int

Deprecated: Use View#LAYER_TYPE_HARDWARE directly.

Indicates that the view has a hardware layer. A hardware layer is backed by a hardware specific texture (generally Frame Buffer Objects or FBO on OpenGL hardware) and causes the view to be rendered using Android's hardware rendering pipeline, but only if hardware acceleration is turned on for the view hierarchy. When hardware acceleration is turned off, hardware layers behave exactly as software layers.

A hardware layer is useful to apply a specific color filter and/or blending mode and/or translucency to a view and all its children.

A hardware layer can be used to cache a complex view tree into a texture and reduce the complexity of drawing operations. For instance, when animating a complex view tree with a translation, a hardware layer can be used to render the view tree only once.

A hardware layer can also be used to increase the rendering quality when rotation transformations are applied on a view. It can also be used to prevent potential clipping issues when applying 3D transforms on a view.

Value: 2

LAYER_TYPE_NONE

static val LAYER_TYPE_NONE: Int

Deprecated: Use View#LAYER_TYPE_NONE directly.

Indicates that the view does not have a layer.

Value: 0

LAYER_TYPE_SOFTWARE

static val LAYER_TYPE_SOFTWARE: Int

Deprecated: Use View#LAYER_TYPE_SOFTWARE directly.

Indicates that the view has a software layer. A software layer is backed by a bitmap and causes the view to be rendered using Android's software rendering pipeline, even if hardware acceleration is enabled.

Software layers have various usages:

When the application is not using hardware acceleration, a software layer is useful to apply a specific color filter and/or blending mode and/or translucency to a view and all its children.

When the application is using hardware acceleration, a software layer is useful to render drawing primitives not supported by the hardware accelerated pipeline. It can also be used to cache a complex view tree into a texture and reduce the complexity of drawing operations. For instance, when animating a complex view tree with a translation, a software layer can be used to render the view tree only once.

Software layers should be avoided when the affected view tree updates often. Every update will require to re-render the software layer, which can potentially be slow (particularly when hardware acceleration is turned on since the layer will have to be uploaded into a hardware texture after every update.)

Value: 1

LAYOUT_DIRECTION_INHERIT

static val LAYOUT_DIRECTION_INHERIT: Int

Horizontal layout direction of this view is inherited from its parent. Use with setLayoutDirection.

Value: 2

LAYOUT_DIRECTION_LOCALE

static val LAYOUT_DIRECTION_LOCALE: Int

Horizontal layout direction of this view is from deduced from the default language script for the locale. Use with setLayoutDirection.

Value: 3

LAYOUT_DIRECTION_LTR

static val LAYOUT_DIRECTION_LTR: Int

Horizontal layout direction of this view is from Left to Right.

Value: 0

LAYOUT_DIRECTION_RTL

static val LAYOUT_DIRECTION_RTL: Int

Horizontal layout direction of this view is from Right to Left.

Value: 1

MEASURED_HEIGHT_STATE_SHIFT

static val MEASURED_HEIGHT_STATE_SHIFT: Int

Deprecated: Use View#MEASURED_HEIGHT_STATE_SHIFT directly.

Bit shift of MEASURED_STATE_MASK to get to the height bits for functions that combine both width and height into a single int, such as getMeasuredState and the childState argument of resolveSizeAndState(int, int, int).

Value: 16

MEASURED_SIZE_MASK

static val MEASURED_SIZE_MASK: Int

Deprecated: Use View#MEASURED_SIZE_MASK directly.

Bits of getMeasuredWidthAndState and getMeasuredWidthAndState that provide the actual measured size.

Value: 0x00ffffff

MEASURED_STATE_MASK

static val MEASURED_STATE_MASK: Int

Deprecated: Use View#MEASURED_STATE_MASK directly.

Bits of getMeasuredWidthAndState and getMeasuredWidthAndState that provide the additional state bits.

Value: 0xff000000

MEASURED_STATE_TOO_SMALL

static val MEASURED_STATE_TOO_SMALL: Int

Deprecated: Use View#MEASURED_STATE_TOO_SMALL directly.

Bit of getMeasuredWidthAndState and getMeasuredWidthAndState that indicates the measured size is smaller that the space the view would like to have.

Value: 0x01000000

OVER_SCROLL_ALWAYS

static val OVER_SCROLL_ALWAYS: Int

Deprecated: Use View#OVER_SCROLL_ALWAYS directly. This constant will be removed in a future release.

Always allow a user to over-scroll this view, provided it is a view that can scroll.

Value: 0

OVER_SCROLL_IF_CONTENT_SCROLLS

static val OVER_SCROLL_IF_CONTENT_SCROLLS: Int

Deprecated: Use View#OVER_SCROLL_IF_CONTENT_SCROLLS directly. This constant will be removed in a future release.

Allow a user to over-scroll this view only if the content is large enough to meaningfully scroll, provided it is a view that can scroll.

Value: 1

OVER_SCROLL_NEVER

static val OVER_SCROLL_NEVER: Int

Deprecated: Use View#OVER_SCROLL_NEVER directly. This constant will be removed in a future release.

Never allow a user to over-scroll this view.

Value: 2

SCROLL_AXIS_HORIZONTAL

static val SCROLL_AXIS_HORIZONTAL: Int

Indicates scrolling along the horizontal axis.

Value: 1 << 0

SCROLL_AXIS_NONE

static val SCROLL_AXIS_NONE: Int

Indicates no axis of view scrolling.

Value: 0

SCROLL_AXIS_VERTICAL

static val SCROLL_AXIS_VERTICAL: Int

Indicates scrolling along the vertical axis.

Value: 1 << 1

SCROLL_INDICATOR_BOTTOM

static val SCROLL_INDICATOR_BOTTOM: Int

Scroll indicator direction for the bottom edge of the view.

Value: 0x2

SCROLL_INDICATOR_END

static val SCROLL_INDICATOR_END: Int

Scroll indicator direction for the ending edge of the view.

Value: 0x20

SCROLL_INDICATOR_LEFT

static val SCROLL_INDICATOR_LEFT: Int

Scroll indicator direction for the left edge of the view.

Value: 0x4

SCROLL_INDICATOR_RIGHT

static val SCROLL_INDICATOR_RIGHT: Int

Scroll indicator direction for the right edge of the view.

Value: 0x8

SCROLL_INDICATOR_START

static val SCROLL_INDICATOR_START: Int

Scroll indicator direction for the starting edge of the view.

Value: 0x10

SCROLL_INDICATOR_TOP

static val SCROLL_INDICATOR_TOP: Int

Scroll indicator direction for the top edge of the view.

Value: 0x1

TYPE_NON_TOUCH

static val TYPE_NON_TOUCH: Int

Indicates that the input type for the gesture is caused by something which is not a user touching a screen. This is usually from a fling which is settling.

Value: 1

TYPE_TOUCH

static val TYPE_TOUCH: Int

Indicates that the input type for the gesture is from a user touching the screen.

Value: 0

Protected constructors

<init>

protected ViewCompat()

Public methods

addAccessibilityAction

open static fun addAccessibilityAction(@NonNull view: View, @NonNull label: CharSequence, @NonNull command: AccessibilityViewCommand): Int

Adds an accessibility action that can be performed on a node associated with a view. A view can only have 32 actions created with this API.

Parameters
view View: The view.
label View: The use facing description of the action.
command View: The command performed when the service requests the action.
Return
Int: The id associated with the action, or View#NO_ID if the action could not be created. This id can be used to remove the action.

Compatibility:

  • API < 21: No-op

addKeyboardNavigationClusters

open static fun addKeyboardNavigationClusters(@NonNull view: View, @NonNull views: MutableCollection<View!>, direction: Int): Unit

Adds any keyboard navigation cluster roots that are descendants of view ( including view if it is a cluster root itself) to views. Does nothing on API < 26.

Parameters
views View: collection of keyboard navigation cluster roots found so far.
direction View: direction to look.

addOnUnhandledKeyEventListener

open static fun addOnUnhandledKeyEventListener(@NonNull v: View, @NonNull listener: ViewCompat.OnUnhandledKeyEventListenerCompat): Unit

Adds a listener which will receive unhandled KeyEvents. This must be called on the UI thread.

Parameters
listener View: a receiver of unhandled KeyEvents.

animate

@NonNull open static fun animate(@NonNull view: View): ViewPropertyAnimatorCompat

This method returns a ViewPropertyAnimator object, which can be used to animate specific properties on this View.

Return
ViewPropertyAnimatorCompat: ViewPropertyAnimator The ViewPropertyAnimator associated with this View.

canScrollHorizontally

open static fun canScrollHorizontally(view: View!, direction: Int): Boolean

Deprecated: Use View#canScrollHorizontally(int) directly.

Check if this view can be scrolled horizontally in a certain direction.

Parameters
view View!: The View against which to invoke the method.
direction View!: Negative to check scrolling left, positive to check scrolling right.
Return
Boolean: true if this view can be scrolled in the specified direction, false otherwise.

canScrollVertically

open static fun canScrollVertically(view: View!, direction: Int): Boolean

Deprecated: Use View#canScrollVertically(int) directly.

Check if this view can be scrolled vertically in a certain direction.

Parameters
view View!: The View against which to invoke the method.
direction View!: Negative to check scrolling up, positive to check scrolling down.
Return
Boolean: true if this view can be scrolled in the specified direction, false otherwise.

cancelDragAndDrop

open static fun cancelDragAndDrop(@NonNull v: View): Unit

Cancel the drag and drop operation.

combineMeasuredStates

open static fun combineMeasuredStates(curState: Int, newState: Int): Int

Deprecated: Use View#combineMeasuredStates(int, int) directly.

Merge two states as returned by getMeasuredState(View).

Parameters
curState Int: The current state as returned from a view or the result of combining multiple views.
newState Int: The new view state to combine.
Return
Int: Returns a new integer reflecting the combination of the two states.

dispatchApplyWindowInsets

open static fun dispatchApplyWindowInsets(@NonNull view: View, insets: WindowInsetsCompat!): WindowInsetsCompat!

Request to apply the given window insets to this view or another view in its subtree.

This method should be called by clients wishing to apply insets corresponding to areas obscured by window decorations or overlays. This can include the status and navigation bars, action bars, input methods and more. New inset categories may be added in the future. The method returns the insets provided minus any that were applied by this view or its children.

Parameters
insets View: Insets to apply
Return
WindowInsetsCompat!: The provided insets minus the insets that were consumed

dispatchFinishTemporaryDetach

open static fun dispatchFinishTemporaryDetach(@NonNull view: View): Unit

Notify a view that its temporary detach has ended; the view is now reattached.

dispatchNestedFling

open static fun dispatchNestedFling(@NonNull view: View, velocityX: Float, velocityY: Float, consumed: Boolean): Boolean

Dispatch a fling to a nested scrolling parent.

This method should be used to indicate that a nested scrolling child has detected suitable conditions for a fling. Generally this means that a touch scroll has ended with a velocity in the direction of scrolling that meets or exceeds the minimum fling velocity along a scrollable axis.

If a nested scrolling child view would normally fling but it is at the edge of its own content, it can use this method to delegate the fling to its nested scrolling parent instead. The parent may optionally consume the fling or observe a child fling.

Parameters
velocityX View: Horizontal fling velocity in pixels per second
velocityY View: Vertical fling velocity in pixels per second
consumed View: true if the child consumed the fling, false otherwise
Return
Boolean: true if the nested scrolling parent consumed or otherwise reacted to the fling

dispatchNestedPreFling

open static fun dispatchNestedPreFling(@NonNull view: View, velocityX: Float, velocityY: Float): Boolean

Dispatch a fling to a nested scrolling parent before it is processed by this view.

Nested pre-fling events are to nested fling events what touch intercept is to touch and what nested pre-scroll is to nested scroll. dispatchNestedPreFling offsets an opportunity for the parent view in a nested fling to fully consume the fling before the child view consumes it. If this method returns true, a nested parent view consumed the fling and this view should not scroll as a result.

For a better user experience, only one view in a nested scrolling chain should consume the fling at a time. If a parent view consumed the fling this method will return false. Custom view implementations should account for this in two ways:

  • If a custom view is paged and needs to settle to a fixed page-point, do not call dispatchNestedPreFling; consume the fling and settle to a valid position regardless.
  • If a nested parent does consume the fling, this view should not scroll at all, even to settle back to a valid idle position.

Views should also not offer fling velocities to nested parent views along an axis where scrolling is not currently supported; a ScrollView should not offer a horizontal fling velocity to its parents since scrolling along that axis is not permitted and carrying velocity along that motion does not make sense.

Parameters
velocityX View: Horizontal fling velocity in pixels per second
velocityY View: Vertical fling velocity in pixels per second
Return
Boolean: true if a nested scrolling parent consumed the fling

dispatchNestedPreScroll

open static fun dispatchNestedPreScroll(@NonNull view: View, dx: Int, dy: Int, @Nullable consumed: IntArray?, @Nullable offsetInWindow: IntArray?): Boolean

Dispatch one step of a nested scroll in progress before this view consumes any portion of it.

This version of the method just calls dispatchNestedPreScroll(View, int, int, int[], int[], int) using the touch input type.

Parameters
dx View: Horizontal scroll distance in pixels
dy View: Vertical scroll distance in pixels
consumed View: Output. If not null, consumed[0] will contain the consumed component of dx and consumed[1] the consumed dy.
offsetInWindow View: Optional. If not null, on return this will contain the offset in local view coordinates of this view from before this operation to after it completes. View implementations may use this to adjust expected input coordinate tracking.
Return
Boolean: true if the parent consumed some or all of the scroll delta

dispatchNestedPreScroll

open static fun dispatchNestedPreScroll(@NonNull view: View, dx: Int, dy: Int, @Nullable consumed: IntArray?, @Nullable offsetInWindow: IntArray?, type: Int): Boolean

Dispatch one step of a nested scroll in progress before this view consumes any portion of it.

Nested pre-scroll events are to nested scroll events what touch intercept is to touch. dispatchNestedPreScroll offers an opportunity for the parent view in a nested scrolling operation to consume some or all of the scroll operation before the child view consumes it.

Parameters
dx View: Horizontal scroll distance in pixels
dy View: Vertical scroll distance in pixels
consumed View: Output. If not null, consumed[0] will contain the consumed component of dx and consumed[1] the consumed dy.
offsetInWindow View: Optional. If not null, on return this will contain the offset in local view coordinates of this view from before this operation to after it completes. View implementations may use this to adjust expected input coordinate tracking.
type View: the type of input which cause this scroll event
Return
Boolean: true if the parent consumed some or all of the scroll delta

dispatchNestedScroll

open static fun dispatchNestedScroll(@NonNull view: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int, @Nullable offsetInWindow: IntArray?): Boolean

Dispatch one step of a nested scroll in progress.

This version of the method just calls dispatchNestedScroll(View, int, int, int, int, int[], int) using the touch input type.

Parameters
dxConsumed View: Horizontal distance in pixels consumed by this view during this scroll step
dyConsumed View: Vertical distance in pixels consumed by this view during this scroll step
dxUnconsumed View: Horizontal scroll distance in pixels not consumed by this view
dyUnconsumed View: Horizontal scroll distance in pixels not consumed by this view
offsetInWindow View: Optional. If not null, on return this will contain the offset in local view coordinates of this view from before this operation to after it completes. View implementations may use this to adjust expected input coordinate tracking.
Return
Boolean: true if the event was dispatched, false if it could not be dispatched.

dispatchNestedScroll

open static fun dispatchNestedScroll(@NonNull view: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int, @Nullable offsetInWindow: IntArray?, type: Int, @NonNull consumed: IntArray): Unit

Dispatch one step of a nested scroll in progress.

Implementations of views that support nested scrolling should call this to report info about a scroll in progress to the current nested scrolling parent. If a nested scroll is not currently in progress or nested scrolling is not enabled for this view this method does nothing.

Compatible View implementations should also call dispatchNestedPreScroll before consuming a component of the scroll event themselves.

A non-null consumed int array of length 2 may be passed in to enable nested scrolling parents to report how much of the scroll distance was consumed. The original caller (where the input event was received to start the scroll) should initialize the values to be 0, in order to tell how much was actually consumed up the hierarchy of scrolling parents.

Parameters
dxConsumed View: Horizontal distance in pixels consumed by this view during this scroll step
dyConsumed View: Vertical distance in pixels consumed by this view during this scroll step
dxUnconsumed View: Horizontal scroll distance in pixels not consumed by this view
dyUnconsumed View: Horizontal scroll distance in pixels not consumed by this view
offsetInWindow View: Optional. If not null, on return this will contain the offset in local view coordinates of this view from before this operation to after it completes. View implementations may use this to adjust expected input coordinate tracking.
type View: the type of input which cause this scroll event
consumed View: Output, If not null, consumed[0] will contain the consumed component of dx and consumed[1] the consumed dy.

dispatchNestedScroll

open static fun dispatchNestedScroll(@NonNull view: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int, @Nullable offsetInWindow: IntArray?, type: Int): Boolean

Dispatch one step of a nested scroll in progress.

Implementations of views that support nested scrolling should call this to report info about a scroll in progress to the current nested scrolling parent. If a nested scroll is not currently in progress or nested scrolling is not enabled for this view this method does nothing.

Compatible View implementations should also call dispatchNestedPreScroll before consuming a component of the scroll event themselves.

Parameters
dxConsumed View: Horizontal distance in pixels consumed by this view during this scroll step
dyConsumed View: Vertical distance in pixels consumed by this view during this scroll step
dxUnconsumed View: Horizontal scroll distance in pixels not consumed by this view
dyUnconsumed View: Horizontal scroll distance in pixels not consumed by this view
offsetInWindow View: Optional. If not null, on return this will contain the offset in local view coordinates of this view from before this operation to after it completes. View implementations may use this to adjust expected input coordinate tracking.
type View: the type of input which cause this scroll event
Return
Boolean: true if the event was dispatched, and therefore the scroll distance was consumed

dispatchStartTemporaryDetach

open static fun dispatchStartTemporaryDetach(@NonNull view: View): Unit

Notify a view that it is being temporarily detached.

enableAccessibleClickableSpanSupport

open static fun enableAccessibleClickableSpanSupport(view: View!): Unit

Allow accessibility services to find and activate clickable spans in the application.

Parameters
view View!: The view

Compatibility:

  • API < 19: No-op

generateViewId

open static fun generateViewId(): Int

Generate a value suitable for use in View#setId(int). This value will not collide with ID values generated at build time by aapt for R.id.

Return
Int: a generated ID value

getAccessibilityDelegate

@Nullable open static fun getAccessibilityDelegate(@NonNull view: View): AccessibilityDelegateCompat?

Get the current accessibility delegate.

Parameters
view View: The view whose delegate is of interest
Return
AccessibilityDelegateCompat?: A compat wrapper for the current delegate. If no delegate is attached, you may still get an object that is being used to provide backward compatibility. Returns null if there is no delegate attached.

getAccessibilityLiveRegion

open static fun getAccessibilityLiveRegion(@NonNull view: View): Int

Gets the live region mode for the specified View.

Parameters
view View: The view from which to obtain the live region mode
Return
Int: The live region mode for the view.

getAccessibilityNodeProvider

open static fun getAccessibilityNodeProvider(@NonNull view: View): AccessibilityNodeProviderCompat!

Gets the provider for managing a virtual view hierarchy rooted at this View and reported to android.accessibilityservice.AccessibilityServices that explore the window content.

If this method returns an instance, this instance is responsible for managing AccessibilityNodeInfoCompats describing the virtual sub-tree rooted at this View including the one representing the View itself. Similarly the returned instance is responsible for performing accessibility actions on any virtual view or the root view itself.

If an AccessibilityDelegateCompat has been specified via calling setAccessibilityDelegate(View, AccessibilityDelegateCompat) its AccessibilityDelegateCompat#getAccessibilityNodeProvider(View) is responsible for handling this call.

Parameters
view View: The view whose property to get.
Return
AccessibilityNodeProviderCompat!: The provider.

getAccessibilityPaneTitle

@UiThread open static fun getAccessibilityPaneTitle(view: View!): CharSequence!

Get the title of the pane for purposes of accessibility.

Parameters
view View!: The view queried for it's pane title.

Compatibility:

  • API < 19: Always returns null
Return
CharSequence!: The current pane title. {@see #setAccessibilityPaneTitle}.

getAlpha

open static fun getAlpha(view: View!): Float

Deprecated: Use View#getAlpha() directly.

The opacity of the view. This is a value from 0 to 1, where 0 means the view is completely transparent and 1 means the view is completely opaque.

By default this is 1.0f.

Return
Float: The opacity of the view.

getBackgroundTintList

open static fun getBackgroundTintList(@NonNull view: View): ColorStateList!

Return the tint applied to the background drawable, if specified.

Only returns meaningful info when running on API v21 or newer, or if view implements the TintableBackgroundView interface.

getBackgroundTintMode

open static fun getBackgroundTintMode(@NonNull view: View): Mode!

Return the blending mode used to apply the tint to the background drawable, if specified.

Only returns meaningful info when running on API v21 or newer, or if view implements the TintableBackgroundView interface.

getClipBounds

@Nullable open static fun getClipBounds(@NonNull view: View): Rect?

Returns a copy of the current setClipBounds(View, Rect).

Prior to API 18 this will return null.

Return
Rect?: A copy of the current clip bounds if clip bounds are set, otherwise null.

getDisplay

@Nullable open static fun getDisplay(@NonNull view: View): Display?

Gets the logical display to which the view's window has been attached.

Compatibility:

  • API < 17: Returns the default display when the view is attached. Otherwise, null.
Return
Display?: The logical display, or null if the view is not currently attached to a window.

getElevation

open static fun getElevation(@NonNull view: View): Float

The base elevation of this view relative to its parent, in pixels.

Return
Float: The base depth position of the view, in pixels.

getFitsSystemWindows

open static fun getFitsSystemWindows(@NonNull v: View): Boolean

Returns true if this view should adapt to fit system window insets. This method will always return false before API 16 (Jellybean).

getImportantForAccessibility

open static fun getImportantForAccessibility(@NonNull view: View): Int

Gets the mode for determining whether this View is important for accessibility which is if it fires accessibility events and if it is reported to accessibility services that query the screen.

Parameters
view View: The view whose property to get.
Return
Int: The mode for determining whether a View is important for accessibility.

getImportantForAutofill

open static fun getImportantForAutofill(@NonNull v: View): Int

Gets the mode for determining whether this view is important for autofill.

See setImportantForAutofill(View, int) and isImportantForAutofill(View) for more info about this mode.

This method is only supported on API >= 26. On API 25 and below, it will always return View#IMPORTANT_FOR_AUTOFILL_AUTO.

Return
Int: View#IMPORTANT_FOR_AUTOFILL_AUTO by default, or value passed to setImportantForAutofill(View, int). android.R.attr#importantForAutofill

getLabelFor

open static fun getLabelFor(@NonNull view: View): Int

Gets the id of a view for which a given view serves as a label for accessibility purposes.

Parameters
view View: The view on which to invoke the corresponding method.
Return
Int: The labeled view id.

getLayerType

open static fun getLayerType(view: View!): Int

Deprecated: Use View#getLayerType() directly.

Indicates what type of layer is currently associated with this view. By default a view does not have a layer, and the layer type is View#LAYER_TYPE_NONE. Refer to the documentation of setLayerType(android.view.View, int, android.graphics.Paint) for more information on the different types of layers.

Parameters
view View!: The view to fetch the layer type from
Return
Int: View#LAYER_TYPE_NONE, View#LAYER_TYPE_SOFTWARE or View#LAYER_TYPE_HARDWARE

getLayoutDirection

open static fun getLayoutDirection(@NonNull view: View): Int

Returns the resolved layout direction for this view.

Parameters
view View: View to get layout direction for
Return
Int: LAYOUT_DIRECTION_RTL if the layout direction is RTL or returns LAYOUT_DIRECTION_LTR if the layout direction is not RTL. For compatibility, this will return LAYOUT_DIRECTION_LTR if API version is lower than Jellybean MR1 (API 17)

getMatrix

@Nullable open static fun getMatrix(view: View!): Matrix?

Deprecated: Use View#getMatrix() directly.

The transform matrix of this view, which is calculated based on the current rotation, scale, and pivot properties.

Parameters
view View!: The view whose Matrix will be returned
Return
Matrix?: The current transform matrix for the view

getMeasuredHeightAndState

open static fun getMeasuredHeightAndState(view: View!): Int

Deprecated: Use View#getMeasuredHeightAndState() directly.

Return the full height measurement information for this view as computed by the most recent call to android.view.View#measure(int, int). This result is a bit mask as defined by MEASURED_SIZE_MASK and MEASURED_STATE_TOO_SMALL. This should be used during measurement and layout calculations only. Use android.view.View#getHeight() to see how wide a view is after layout.

Return
Int: The measured width of this view as a bit mask.

getMeasuredState

open static fun getMeasuredState(view: View!): Int

Deprecated: Use View#getMeasuredState() directly.

Return only the state bits of getMeasuredWidthAndState and getMeasuredHeightAndState, combined into one integer. The width component is in the regular bits MEASURED_STATE_MASK and the height component is at the shifted bits MEASURED_HEIGHT_STATE_SHIFT>>MEASURED_STATE_MASK.

getMeasuredWidthAndState

open static fun getMeasuredWidthAndState(view: View!): Int

Deprecated: Use View#getMeasuredWidth() directly.

Return the full width measurement information for this view as computed by the most recent call to android.view.View#measure(int, int). This result is a bit mask as defined by MEASURED_SIZE_MASK and MEASURED_STATE_TOO_SMALL. This should be used during measurement and layout calculations only. Use android.view.View#getWidth() to see how wide a view is after layout.

Return
Int: The measured width of this view as a bit mask.

getMinimumHeight

open static fun getMinimumHeight(@NonNull view: View): Int

Returns the minimum height of the view.

Prior to API 16, this method may return 0 on some platforms.

Return
Int: the minimum height the view will try to be.

getMinimumWidth

open static fun getMinimumWidth(@NonNull view: View): Int

Returns the minimum width of the view.

Prior to API 16, this method may return 0 on some platforms.

Return
Int: the minimum width the view will try to be.

getNextClusterForwardId

open static fun getNextClusterForwardId(@NonNull view: View): Int

Gets the ID of the next keyboard navigation cluster root.

Return
Int: the next keyboard navigation cluster ID, or View#NO_ID if the framework should decide automatically or API < 26.

getOverScrollMode

open static fun getOverScrollMode(v: View!): Int

Deprecated: Call View#getOverScrollMode() directly. This method will be removed in a future release.

Returns the over-scroll mode for this view. The result will be one of OVER_SCROLL_ALWAYS (default), OVER_SCROLL_IF_CONTENT_SCROLLS (allow over-scrolling only if the view content is larger than the container), or OVER_SCROLL_NEVER.

Parameters
v View!: The View against which to invoke the method.
Return
Int: This view's over-scroll mode.

getPaddingEnd

@Px open static fun getPaddingEnd(@NonNull view: View): Int

Returns the end padding of the specified view depending on its resolved layout direction. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.

Parameters
view View: The view to get padding for
Return
Int: the end padding in pixels

getPaddingStart

@Px open static fun getPaddingStart(@NonNull view: View): Int

Returns the start padding of the specified view depending on its resolved layout direction. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.

Parameters
view View: The view to get padding for
Return
Int: the start padding in pixels

getParentForAccessibility

open static fun getParentForAccessibility(@NonNull view: View): ViewParent!

Gets the parent for accessibility purposes. Note that the parent for accessibility is not necessary the immediate parent. It is the first predecessor that is important for accessibility.

Parameters
view View: View to retrieve parent for
Return
ViewParent!: The parent for use in accessibility inspection

getPivotX

open static fun getPivotX(view: View!): Float

Deprecated: Use View#getPivotX() directly.

The x location of the point around which the view is rotated and scaled.

getPivotY

open static fun getPivotY(view: View!): Float

Deprecated: Use View#getPivotY() directly.

The y location of the point around which the view is rotated and scaled.

Return
Float: The y location of the pivot point.

getRotation

open static fun getRotation(view: View!): Float

Deprecated: Use View#getRotation() directly.

getRotationX

open static fun getRotationX(view: View!): Float

Deprecated: Use View#getRotationX() directly.

getRotationY

open static fun getRotationY(view: View!): Float

Deprecated: Use View#getRotationY() directly.

getScaleX

open static fun getScaleX(view: View!): Float

Deprecated: Use View#getScaleX() directly.

getScaleY

open static fun getScaleY(view: View!): Float

Deprecated: Use View#getScaleY() directly.

getScrollIndicators

open static fun getScrollIndicators(@NonNull view: View): Int

Returns a bitmask representing the enabled scroll indicators.

For example, if the top and left scroll indicators are enabled and all other indicators are disabled, the return value will be ViewCompat.SCROLL_INDICATOR_TOP | ViewCompat.SCROLL_INDICATOR_LEFT.

To check whether the bottom scroll indicator is enabled, use the value of (ViewCompat.getScrollIndicators(view) & ViewCompat.SCROLL_INDICATOR_BOTTOM) != 0.

Return
Int: a bitmask representing the enabled scroll indicators

getSystemGestureExclusionRects

@NonNull open static fun getSystemGestureExclusionRects(@NonNull view: View): MutableList<Rect!>

Retrieve the list of areas within this view's post-layout coordinate space where the system should not intercept touch or other pointing device gestures.

On devices running API 28 and below, this method always returns an empty list.

getTransitionName

@Nullable open static fun getTransitionName(@NonNull view: View): String?

Returns the name of the View to be used to identify Views in Transitions. Names should be unique in the View hierarchy.

This returns null if the View has not been given a name.

Parameters
view View: The View against which to invoke the method.
Return
String?: The name used of the View to be used to identify Views in Transitions or null if no name has been given.

getTranslationX

open static fun getTranslationX(view: View!): Float

Deprecated: Use View#getTranslationX() directly.

The horizontal location of this view relative to its left position. This position is post-layout, in addition to wherever the object's layout placed it.

Return
Float: The horizontal position of this view relative to its left position, in pixels.

getTranslationY

open static fun getTranslationY(view: View!): Float

Deprecated: Use View#getTranslationY() directly.

The vertical location of this view relative to its top position. This position is post-layout, in addition to wherever the object's layout placed it.

Return
Float: The vertical position of this view relative to its top position, in pixels.

getTranslationZ

open static fun getTranslationZ(@NonNull view: View): Float

The depth location of this view relative to its elevation.

Return
Float: The depth of this view relative to its elevation.

getWindowSystemUiVisibility

open static fun getWindowSystemUiVisibility(@NonNull view: View): Int

Returns the current system UI visibility that is currently set for the entire window.

getX

open static fun getX(view: View!): Float

Deprecated: Use View#getX() directly.

getY

open static fun getY(view: View!): Float

Deprecated: Use View#getY() directly.

getZ

open static fun getZ(@NonNull view: View): Float

The visual z position of this view, in pixels. This is equivalent to the translationZ property plus the current elevation property.

Return
Float: The visual z position of this view, in pixels.

hasAccessibilityDelegate

open static fun hasAccessibilityDelegate(@NonNull view: View): Boolean

Checks whether provided View has an accessibility delegate attached to it.

Parameters
view View: The View instance to check
Return
Boolean: True if the View has an accessibility delegate

hasExplicitFocusable

open static fun hasExplicitFocusable(@NonNull view: View): Boolean

Returns true if this view is focusable or if it contains a reachable View for which View#hasExplicitFocusable() returns true. A "reachable hasExplicitFocusable()" is a view whose parents do not block descendants focus. Only View#VISIBLE views for which View#getFocusable() would return View#FOCUSABLE are considered focusable.

This method preserves the pre-Build.VERSION_CODES#O behavior of View#hasFocusable() in that only views explicitly set focusable will cause this method to return true. A view set to View#FOCUSABLE_AUTO that resolves to focusable will not.

Return
Boolean: true if the view is focusable or if the view contains a focusable view, false otherwise

hasNestedScrollingParent

open static fun hasNestedScrollingParent(@NonNull view: View): Boolean

Returns true if this view has a nested scrolling parent.

This version of the method just calls hasNestedScrollingParent(View, int) using the touch input type.

Return
Boolean: whether this view has a nested scrolling parent

hasNestedScrollingParent

open static fun hasNestedScrollingParent(@NonNull view: View, type: Int): Boolean

Returns true if this view has a nested scrolling parent.

The presence of a nested scrolling parent indicates that this view has initiated a nested scroll and it was accepted by an ancestor view further up the view hierarchy.

Parameters
type View: the type of input which cause this scroll event
Return
Boolean: whether this view has a nested scrolling parent

hasOnClickListeners

open static fun hasOnClickListeners(@NonNull view: View): Boolean

Returns whether the provided view has an attached View.OnClickListener.

Return
Boolean: true if there is a listener, false if there is none.

hasOverlappingRendering

open static fun hasOverlappingRendering(@NonNull view: View): Boolean

Returns whether this View has content which overlaps.

This function, intended to be overridden by specific View types, is an optimization when alpha is set on a view. If rendering overlaps in a view with alpha < 1, that view is drawn to an offscreen buffer and then composited into place, which can be expensive. If the view has no overlapping rendering, the view can draw each primitive with the appropriate alpha value directly. An example of overlapping rendering is a TextView with a background image, such as a Button. An example of non-overlapping rendering is a TextView with no background, or an ImageView with only the foreground image. The default implementation returns true; subclasses should override if they have cases which can be optimized.

Return
Boolean: true if the content in this view might overlap, false otherwise.

hasTransientState

open static fun hasTransientState(@NonNull view: View): Boolean

Indicates whether the view is currently tracking transient state that the app should not need to concern itself with saving and restoring, but that the framework should take special note to preserve when possible.

Parameters
view View: View to check for transient state
Return
Boolean: true if the view has transient state

isAccessibilityHeading

@UiThread open static fun isAccessibilityHeading(view: View!): Boolean

Gets whether this view is a heading for accessibility purposes.

Parameters
view View!: The view checked if it is a heading.

Compatibility:

  • API < 19: Always returns false
Return
Boolean: true if the view is a heading, false otherwise.

isAttachedToWindow

open static fun isAttachedToWindow(@NonNull view: View): Boolean

Returns true if the provided view is currently attached to a window.

isFocusedByDefault

open static fun isFocusedByDefault(@NonNull view: View): Boolean

Returns whether view should receive focus when the focus is restored for the view hierarchy containing it. Returns false on API < 26.

Focus gets restored for a view hierarchy when the root of the hierarchy gets added to a window or serves as a target of cluster navigation.

Return
Boolean: true if view is the default-focus view, false otherwise.

isImportantForAccessibility

open static fun isImportantForAccessibility(@NonNull view: View): Boolean

Computes whether this view should be exposed for accessibility. In general, views that are interactive or provide information are exposed while views that serve only as containers are hidden.

If an ancestor of this view has importance IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS, this method returns false.

Otherwise, the value is computed according to the view's getImportantForAccessibility(View) value:

  1. IMPORTANT_FOR_ACCESSIBILITY_NO or IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS, return false
  2. IMPORTANT_FOR_ACCESSIBILITY_YES, return true
  3. IMPORTANT_FOR_ACCESSIBILITY_AUTO, return true if view satisfies any of the following:

Note: Prior to API 21, this method will always return true.

Return