ViewCompat

public class ViewCompat
extends Object

java.lang.Object
   ↳ androidx.core.view.ViewCompat


Helper for accessing features in View.

Summary

Nested classes

interface ViewCompat.OnUnhandledKeyEventListenerCompat

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

Constants

int ACCESSIBILITY_LIVE_REGION_ASSERTIVE

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

int ACCESSIBILITY_LIVE_REGION_NONE

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

int ACCESSIBILITY_LIVE_REGION_POLITE

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

int IMPORTANT_FOR_ACCESSIBILITY_AUTO

Automatically determine whether a view is important for accessibility.

int IMPORTANT_FOR_ACCESSIBILITY_NO

The view is not important for accessibility.

int IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS

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

int IMPORTANT_FOR_ACCESSIBILITY_YES

The view is important for accessibility.

int LAYER_TYPE_HARDWARE

This constant is deprecated. Use View.LAYER_TYPE_HARDWARE directly.

int LAYER_TYPE_NONE

This constant is deprecated. Use View.LAYER_TYPE_NONE directly.

int LAYER_TYPE_SOFTWARE

This constant is deprecated. Use View.LAYER_TYPE_SOFTWARE directly.

int LAYOUT_DIRECTION_INHERIT

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

int LAYOUT_DIRECTION_LOCALE

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

int LAYOUT_DIRECTION_LTR

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

int LAYOUT_DIRECTION_RTL

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

int MEASURED_HEIGHT_STATE_SHIFT

This constant is deprecated. Use View.MEASURED_HEIGHT_STATE_SHIFT directly.

int MEASURED_SIZE_MASK

This constant is deprecated. Use View.MEASURED_SIZE_MASK directly.

int MEASURED_STATE_MASK

This constant is deprecated. Use View.MEASURED_STATE_MASK directly.

int MEASURED_STATE_TOO_SMALL

This constant is deprecated. Use View.MEASURED_STATE_TOO_SMALL directly.

int OVER_SCROLL_ALWAYS

This constant is deprecated. Use View.OVER_SCROLL_ALWAYS directly. This constant will be removed in a future release.

int OVER_SCROLL_IF_CONTENT_SCROLLS

This constant is deprecated. Use View.OVER_SCROLL_IF_CONTENT_SCROLLS directly. This constant will be removed in a future release.

int OVER_SCROLL_NEVER

This constant is deprecated. Use View.OVER_SCROLL_NEVER directly. This constant will be removed in a future release.

int SCROLL_AXIS_HORIZONTAL

Indicates scrolling along the horizontal axis.

int SCROLL_AXIS_NONE

Indicates no axis of view scrolling.

int SCROLL_AXIS_VERTICAL

Indicates scrolling along the vertical axis.

int SCROLL_INDICATOR_BOTTOM

Scroll indicator direction for the bottom edge of the view.

int SCROLL_INDICATOR_END

Scroll indicator direction for the ending edge of the view.

int SCROLL_INDICATOR_LEFT

Scroll indicator direction for the left edge of the view.

int SCROLL_INDICATOR_RIGHT

Scroll indicator direction for the right edge of the view.

int SCROLL_INDICATOR_START

Scroll indicator direction for the starting edge of the view.

int SCROLL_INDICATOR_TOP

Scroll indicator direction for the top edge of the view.

int TYPE_NON_TOUCH

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

int TYPE_TOUCH

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

Protected constructors

ViewCompat()

This constructor is deprecated. This is a utility class and it shouldn't be instantiated.

Public methods

static int addAccessibilityAction(View view, CharSequence label, AccessibilityViewCommand command)

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

static void addKeyboardNavigationClusters(View view, Collection<View> views, int direction)

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

static void addOnUnhandledKeyEventListener(View v, ViewCompat.OnUnhandledKeyEventListenerCompat listener)

Adds a listener which will receive unhandled KeyEvents.

static ViewPropertyAnimatorCompat animate(View view)

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

static boolean canScrollHorizontally(View view, int direction)

This method is deprecated. Use View.canScrollHorizontally(int) directly.

static boolean canScrollVertically(View view, int direction)

This method is deprecated. Use View.canScrollVertically(int) directly.

static void cancelDragAndDrop(View v)

Cancel the drag and drop operation.

static int combineMeasuredStates(int curState, int newState)

This method is deprecated. Use View.combineMeasuredStates(int, int) directly.

static WindowInsetsCompat computeSystemWindowInsets(View view, WindowInsetsCompat insets, Rect outLocalInsets)

Compute insets that should be consumed by this view and the ones that should propagate to those under it.

static WindowInsetsCompat dispatchApplyWindowInsets(View view, WindowInsetsCompat insets)

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

static void dispatchFinishTemporaryDetach(View view)

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

static boolean dispatchNestedFling(View view, float velocityX, float velocityY, boolean consumed)

Dispatch a fling to a nested scrolling parent.

static boolean dispatchNestedPreFling(View view, float velocityX, float velocityY)

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

static boolean dispatchNestedPreScroll(View view, int dx, int dy, int[] consumed, int[] offsetInWindow, int type)

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

static boolean dispatchNestedPreScroll(View view, int dx, int dy, int[] consumed, int[] offsetInWindow)

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

static boolean dispatchNestedScroll(View view, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow, int type)

Dispatch one step of a nested scroll in progress.

static boolean dispatchNestedScroll(View view, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow)

Dispatch one step of a nested scroll in progress.

static void dispatchNestedScroll(View view, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow, int type, int[] consumed)

Dispatch one step of a nested scroll in progress.

static void dispatchStartTemporaryDetach(View view)

Notify a view that it is being temporarily detached.

static void enableAccessibleClickableSpanSupport(View view)

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

static int generateViewId()

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

static AccessibilityDelegateCompat getAccessibilityDelegate(View view)

Get the current accessibility delegate.

static int getAccessibilityLiveRegion(View view)

Gets the live region mode for the specified View.

static AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view)

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

static CharSequence getAccessibilityPaneTitle(View view)

Get the title of the pane for purposes of accessibility.

static float getAlpha(View view)

This method is deprecated. Use View.getAlpha() directly.

static ColorStateList getBackgroundTintList(View view)

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

static PorterDuff.Mode getBackgroundTintMode(View view)

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

static Rect getClipBounds(View view)

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

static Display getDisplay(View view)

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

static float getElevation(View view)

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

static boolean getFitsSystemWindows(View v)

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

static int getImportantForAccessibility(View view)

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.

static int getImportantForAutofill(View v)

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

static int getLabelFor(View view)

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

static int getLayerType(View view)

This method is deprecated. Use View.getLayerType() directly.

static int getLayoutDirection(View view)

Returns the resolved layout direction for this view.

static Matrix getMatrix(View view)

This method is deprecated. Use View.getMatrix() directly.

static int getMeasuredHeightAndState(View view)

This method is deprecated. Use View.getMeasuredHeightAndState() directly.

static int getMeasuredState(View view)

This method is deprecated. Use View.getMeasuredState() directly.

static int getMeasuredWidthAndState(View view)

This method is deprecated. Use View.getMeasuredWidth() directly.

static int getMinimumHeight(View view)

Returns the minimum height of the view.

static int getMinimumWidth(View view)

Returns the minimum width of the view.

static int getNextClusterForwardId(View view)

Gets the ID of the next keyboard navigation cluster root.

static String[] getOnReceiveContentMimeTypes(View view)

Returns the MIME types accepted by the listener configured on the given view via setOnReceiveContentListener(View, String[], OnReceiveContentListener).

static int getOverScrollMode(View v)

This method is deprecated. Call View.getOverScrollMode() directly. This method will be removed in a future release.

static int getPaddingEnd(View view)

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

static int getPaddingStart(View view)

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

static ViewParent getParentForAccessibility(View view)

Gets the parent for accessibility purposes.

static float getPivotX(View view)

This method is deprecated. Use View.getPivotX() directly.

static float getPivotY(View view)

This method is deprecated. Use View.getPivotY() directly.

static WindowInsetsCompat getRootWindowInsets(View view)

Provide original WindowInsetsCompat that are dispatched to the view hierarchy.

static float