Stay organized with collections Save and categorize content based on your preferences.
added in version 22.1.0
belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1

ViewCompat

public class ViewCompat
extends Object

java.lang.Object
   ↳ android.support.v4.view.ViewCompat
Known Direct Subclasses


Helper for accessing features in View.

Summary

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 was deprecated in API level 26.1.0. Use LAYER_TYPE_HARDWARE directly.

int LAYER_TYPE_NONE

This constant was deprecated in API level 26.1.0. Use LAYER_TYPE_NONE directly.

int LAYER_TYPE_SOFTWARE

This constant was deprecated in API level 26.1.0. Use 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 was deprecated in API level 26.1.0. Use MEASURED_HEIGHT_STATE_SHIFT directly.

int MEASURED_SIZE_MASK

This constant was deprecated in API level 26.1.0. Use MEASURED_SIZE_MASK directly.

int MEASURED_STATE_MASK

This constant was deprecated in API level 26.1.0. Use MEASURED_STATE_MASK directly.

int MEASURED_STATE_TOO_SMALL

This constant was deprecated in API level 26.1.0. Use MEASURED_STATE_TOO_SMALL directly.

int OVER_SCROLL_ALWAYS

This constant was deprecated in API level 25.1.0. Use OVER_SCROLL_ALWAYS directly. This constant will be removed in a future release.

int OVER_SCROLL_IF_CONTENT_SCROLLS

This constant was deprecated in API level 25.1.0. Use OVER_SCROLL_IF_CONTENT_SCROLLS directly. This constant will be removed in a future release.

int OVER_SCROLL_NEVER

This constant was deprecated in API level 25.1.0. Use 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()

Public methods

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 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 was deprecated in API level 26.1.0. Use canScrollHorizontally(int) directly.

static boolean canScrollVertically(View view, int direction)

This method was deprecated in API level 26.1.0. Use canScrollVertically(int) directly.

static void cancelDragAndDrop(View v)

Cancel the drag and drop operation.

static int combineMeasuredStates(int curState, int newState)

This method was deprecated in API level 26.1.0. Use combineMeasuredStates(int, int) directly.

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 dispatchStartTemporaryDetach(View view)

Notify a view that it is being temporarily detached.

static int generateViewId()

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

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 float getAlpha(View view)

This method was deprecated in API level 26.1.0. Use 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 was deprecated in API level 26.1.0. Use getLayerType() directly.

static int getLayoutDirection(View view)

Returns the resolved layout direction for this view.

static Matrix getMatrix(View view)

This method was deprecated in API level 26.1.0. Use getMatrix() directly.

static int getMeasuredHeightAndState(View view)

This method was deprecated in API level 26.1.0. Use getMeasuredHeightAndState() directly.

static int getMeasuredState(View view)

This method was deprecated in API level 26.1.0. Use getMeasuredState() directly.

static int getMeasuredWidthAndState(View view)

This method was deprecated in API level 26.1.0. Use 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 int getOverScrollMode(View v)

This method was deprecated in API level 25.1.0. Call 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 was deprecated in API level 26.1.0. Use getPivotX() directly.

static float getPivotY(View view)

This method was deprecated in API level 26.1.0. Use getPivotY() directly.

static float getRotation(View view)

This method was deprecated in API level 26.1.0. Use getRotation() directly.

static float getRotationX(View view)

This method was deprecated in API level 26.1.0. Use getRotationX() directly.

static float getRotationY(View view)

This method was deprecated in API level 26.1.0. Use getRotationY() directly.

static float getScaleX(View view)

This method was deprecated in API level 26.1.0. Use getScaleX() directly.

static float getScaleY(View view)

This method was deprecated in API level 26.1.0. Use getScaleY() directly.

static int getScrollIndicators(View view)

Returns a bitmask representing the enabled scroll indicators.

static String getTransitionName(View view)

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

static float getTranslationX(View view)

This method was deprecated in API level 26.1.0. Use getTranslationX() directly.

static float getTranslationY(View view)

This method was deprecated in API level 26.1.0. Use getTranslationY() directly.

static float getTranslationZ(View view)

The depth location of this view relative to its elevation.

static int getWindowSystemUiVisibility(View view)

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

static float getX(View view)

This method was deprecated in API level 26.1.0. Use getX() directly.

static float getY(View view)

This method was deprecated in API level 26.1.0. Use getY() directly.

static float getZ(View view)

The visual z position of this view, in pixels.

static boolean hasAccessibilityDelegate(View v)

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

static boolean hasExplicitFocusable(View view)

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

static boolean hasNestedScrollingParent(View view, int type)

Returns true if this view has a nested scrolling parent.

static boolean hasNestedScrollingParent(View view)

Returns true if this view has a nested scrolling parent.

static boolean hasOnClickListeners(View view)

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

static boolean hasOverlappingRendering(View view)

Returns whether this View has content which overlaps.

static boolean hasTransientState(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.

static boolean isAttachedToWindow(View view)

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

static boolean isFocusedByDefault(View view)

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

static boolean isImportantForAccessibility(View view)

Computes whether this view should be exposed for accessibility.

static boolean isImportantForAutofill(View v)

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

static boolean isInLayout(View view)

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

static boolean isKeyboardNavigationCluster(View view)

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

static boolean isLaidOut(View view)

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

static boolean isLayoutDirectionResolved(View view)

Returns whether layout direction has been resolved.

static boolean isNestedScrollingEnabled(View view)

Returns true if nested scrolling is enabled for this view.

static boolean isOpaque(View view)

This method was deprecated in API level 25.1.0. Use isOpaque() directly. This method will be removed in a future release.

static boolean isPaddingRelative(View view)

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

static void jumpDrawablesToCurrentState(View v)

This method was deprecated in API level 26.1.0. Use jumpDrawablesToCurrentState() directly.

static View keyboardNavigationClusterSearch(View view, View currentCluster, int direction)

Find the nearest keyboard navigation cluster in the specified direction.

static void offsetLeftAndRight(View view, int offset)

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

static void offsetTopAndBottom(View view, int offset)

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

static WindowInsetsCompat onApplyWindowInsets(View view, WindowInsetsCompat insets)

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

static void onInitializeAccessibilityEvent(View v, AccessibilityEvent event)

This method was deprecated in API level 26.1.0. Call onInitializeAccessibilityEvent(AccessibilityEvent) directly. This method will be removed in a future release.

static void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info)

Initializes an AccessibilityNodeInfoCompat with information about this view.

static void onPopulateAccessibilityEvent(View v, AccessibilityEvent event)

This method was deprecated in API level 26.1.0. Call onPopulateAccessibilityEvent(AccessibilityEvent) directly. This method will be removed in a future release.

static boolean performAccessibilityAction(View view, int action, Bundle arguments)

Performs the specified accessibility action on the view.

static void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom)

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

static void postInvalidateOnAnimation(View view)

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

static void postOnAnimation(View view, Runnable action)

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

static void postOnAnimationDelayed(View view, Runnable action, long delayMillis)

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

static void requestApplyInsets(View view)

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

static <T extends View> T requireViewById(View view, int id)

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

static int resolveSizeAndState(int size, int measureSpec, int childMeasuredState)

This method was deprecated in API level 26.1.0. Use resolveSizeAndState(int, int, int) directly.

static boolean restoreDefaultFocus(View view)

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

static void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate)

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

static void setAccessibilityLiveRegion(View view, int mode)

Sets the live region mode for the specified view.

static void setActivated(View view, boolean activated)

This method was deprecated in API level 26.1.0. Use setActivated(boolean) directly.

static void setAlpha(View view, float value)

This method was deprecated in API level 26.1.0. Use setAlpha(float) directly.

static void setAutofillHints(View v, String... autofillHints)

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

static void setBackground(View view, Drawable background)

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

static void setBackgroundTintList(View view, ColorStateList tintList)

Applies a tint to the background drawable.

static void setBackgroundTintMode(View view, PorterDuff.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.

static void setChildrenDrawingOrderEnabled(ViewGroup viewGroup, boolean enabled)

This method was deprecated in API level 27.1.0. Use setChildrenDrawingOrderEnabled(boolean) directly.

static void setClipBounds(View view, Rect clipBounds)

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

static void setElevation(View view, float elevation)

Sets the base elevation of this view, in pixels.

static void setFitsSystemWindows(View view, boolean fitSystemWindows)

This method was deprecated in API level 26.1.0. Use setFitsSystemWindows(boolean) directly.

static void setFocusedByDefault(View view, boolean isFocusedByDefault)

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

static void setHasTransientState(View view, boolean hasTransientState)

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

static void setImportantForAccessibility(View view, int mode)

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.

static void setImportantForAutofill(View v, int mode)

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

static void setKeyboardNavigationCluster(View view, boolean isCluster)

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

static void setLabelFor(View view, int labeledId)

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

static void setLayerPaint(View view, Paint paint)

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

static void setLayerType(View view, int layerType, Paint paint)

This method was deprecated in API level 26.1.0. Use setLayerType(int, Paint) directly.

static void setLayoutDirection(View view, int layoutDirection)

Set the layout direction for this view.

static void setNestedScrollingEnabled(View view, boolean enabled)

Enable or disable nested scrolling for this view.

static void setNextClusterForwardId(View view, int nextClusterForwardId)

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

static void setOnApplyWindowInsetsListener(View v, OnApplyWindowInsetsListener listener)

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

static void setOverScrollMode(View v, int overScrollMode)

This method was deprecated in API level 25.1.0. Call setOverScrollMode(int) directly. This method will be removed in a future release.

static void setPaddingRelative(View view, int start, int top, int end, int bottom)

Sets the relative padding.

static void setPivotX(View view, float value)

This method was deprecated in API level 26.1.0. Use setPivotX(float) directly.

static void setPivotY(View view, float value)

This method was deprecated in API level 26.1.0. Use setPivotX(float) directly.

static void setPointerIcon(View view, PointerIconCompat pointerIcon)

Set the pointer icon for the current view.

static void setRotation(View view, float value)

This method was deprecated in API level 26.1.0. Use setRotation(float) directly.

static void setRotationX(View view, float value)

This method was deprecated in API level 26.1.0. Use setRotationX(float) directly.

static void setRotationY(View view, float value)

This method was deprecated in API level 26.1.0. Use setRotationY(float) directly.

static void setSaveFromParentEnabled(View v, boolean enabled)

This method was deprecated in API level 26.1.0. Use setSaveFromParentEnabled(boolean) directly.

static void setScaleX(View view, float value)

This method was deprecated in API level 26.1.0. Use setScaleX(float) directly.

static void setScaleY(View view, float value)

This method was deprecated in API level 26.1.0. Use setScaleY(float) directly.

static void setScrollIndicators(View view, int indicators, int mask)

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

static void setScrollIndicators(View view, int indicators)

Sets the state of all scroll indicators.

static void setTooltipText(View view, CharSequence tooltipText)

Sets the tooltip for the view.

static void setTransitionName(View view, String transitionName)

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

static void setTranslationX(View view, float value)

This method was deprecated in API level 26.1.0. Use setTranslationX(float) directly.

static void setTranslationY(View view, float value)

This method was deprecated in API level 26.1.0. Use setTranslationY(float) directly.

static void setTranslationZ(View view, float translationZ)

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

static void setX(View view, float value)

This method was deprecated in API level 26.1.0. Use setX(float) directly.

static void setY(View view, float value)

This method was deprecated in API level 26.1.0. Use setY(float) directly.

static void setZ(View view, float z)

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

static boolean startDragAndDrop(View v, ClipData data, View.DragShadowBuilder shadowBuilder, Object localState, int flags)

Start the drag and drop operation.

static boolean startNestedScroll(View view, int axes, int type)

Begin a nestable scroll operation along the given axes.

static boolean startNestedScroll(View view, int axes)

Begin a nestable scroll operation along the given axes.

static void stopNestedScroll(View view, int type)

Stop a nested scroll in progress.

static void stopNestedScroll(View view)

Stop a nested scroll in progress.

static void updateDragShadow(View v, View.DragShadowBuilder shadowBuilder)

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

Inherited methods

From class java.lang.Object

Constants

ACCESSIBILITY_LIVE_REGION_ASSERTIVE

added in version 22.1.0
int ACCESSIBILITY_LIVE_REGION_ASSERTIVE

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

Use with setAccessibilityLiveRegion(View, int).

Constant Value: 2 (0x00000002)

ACCESSIBILITY_LIVE_REGION_NONE

added in version 22.1.0
int ACCESSIBILITY_LIVE_REGION_NONE

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 setAccessibilityLiveRegion(View, int).

Constant Value: 0 (0x00000000)

ACCESSIBILITY_LIVE_REGION_POLITE

added in version 22.1.0
int ACCESSIBILITY_LIVE_REGION_POLITE

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

Use with setAccessibilityLiveRegion(View, int).

Constant Value: 1 (0x00000001)

IMPORTANT_FOR_ACCESSIBILITY_AUTO

added in version 22.1.0
int IMPORTANT_FOR_ACCESSIBILITY_AUTO

Automatically determine whether a view is important for accessibility.

Constant Value: 0 (0x00000000)

IMPORTANT_FOR_ACCESSIBILITY_NO

added in version 22.1.0
int IMPORTANT_FOR_ACCESSIBILITY_NO

The view is not important for accessibility.

Constant Value: 2 (0x00000002)

IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS

added in version 22.1.0
int IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS

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

Constant Value: 4 (0x00000004)

IMPORTANT_FOR_ACCESSIBILITY_YES

added in version 22.1.0
int IMPORTANT_FOR_ACCESSIBILITY_YES

The view is important for accessibility.

Constant Value: 1 (0x00000001)

LAYER_TYPE_HARDWARE

added in version 22.1.0
int LAYER_TYPE_HARDWARE

This constant was deprecated in API level 26.1.0.
Use 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.

Constant Value: 2 (0x00000002)

LAYER_TYPE_NONE

added in version 22.1.0
int LAYER_TYPE_NONE

This constant was deprecated in API level 26.1.0.
Use LAYER_TYPE_NONE directly.

Indicates that the view does not have a layer.

Constant Value: 0 (0x00000000)

LAYER_TYPE_SOFTWARE

added in version 22.1.0
int LAYER_TYPE_SOFTWARE

This constant was deprecated in API level 26.1.0.
Use 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.)

Constant Value: 1 (0x00000001)

LAYOUT_DIRECTION_INHERIT

added in version 22.1.0
int LAYOUT_DIRECTION_INHERIT

Horizontal layout direction of this view is inherited from its parent. Use with setLayoutDirection(View, int).

Constant Value: 2 (0x00000002)

LAYOUT_DIRECTION_LOCALE

added in version 22.1.0
int LAYOUT_DIRECTION_LOCALE

Horizontal layout direction of this view is from deduced from the default language script for the locale. Use with setLayoutDirection(View, int).

Constant Value: 3 (0x00000003)

LAYOUT_DIRECTION_LTR

added in version 22.1.0
int LAYOUT_DIRECTION_LTR

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

Constant Value: 0 (0x00000000)

LAYOUT_DIRECTION_RTL

added in version 22.1.0
int LAYOUT_DIRECTION_RTL

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

Constant Value: 1 (0x00000001)

MEASURED_HEIGHT_STATE_SHIFT

added in version 22.1.0
int MEASURED_HEIGHT_STATE_SHIFT

This constant was deprecated in API level 26.1.0.
Use 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(View) and the childState argument of resolveSizeAndState(int, int, int).

Constant Value: 16 (0x00000010)

MEASURED_SIZE_MASK

added in version 22.1.0
int MEASURED_SIZE_MASK

This constant was deprecated in API level 26.1.0.
Use MEASURED_SIZE_MASK directly.

Bits of getMeasuredWidthAndState(View) and getMeasuredWidthAndState(View) that provide the actual measured size.

Constant Value: 16777215 (0x00ffffff)

MEASURED_STATE_MASK

added in version 22.1.0
int MEASURED_STATE_MASK

This constant was deprecated in API level 26.1.0.
Use MEASURED_STATE_MASK directly.

Bits of getMeasuredWidthAndState(View) and getMeasuredWidthAndState(View) that provide the additional state bits.

Constant Value: -16777216 (0xff000000)

MEASURED_STATE_TOO_SMALL

added in version 22.1.0
int MEASURED_STATE_TOO_SMALL

This constant was deprecated in API level 26.1.0.
Use MEASURED_STATE_TOO_SMALL directly.

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

Constant Value: 16777216 (0x01000000)

OVER_SCROLL_ALWAYS

added in version 22.1.0
int OVER_SCROLL_ALWAYS

This constant was deprecated in API level 25.1.0.
Use 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.

Constant Value: 0 (0x00000000)

OVER_SCROLL_IF_CONTENT_SCROLLS

added in version 22.1.0
int OVER_SCROLL_IF_CONTENT_SCROLLS

This constant was deprecated in API level 25.1.0.
Use 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.

Constant Value: 1 (0x00000001)

OVER_SCROLL_NEVER

added in version 22.1.0
int OVER_SCROLL_NEVER

This constant was deprecated in API level 25.1.0.
Use OVER_SCROLL_NEVER directly. This constant will be removed in a future release.

Never allow a user to over-scroll this view.

Constant Value: 2 (0x00000002)

SCROLL_AXIS_HORIZONTAL

added in version 22.1.0
int SCROLL_AXIS_HORIZONTAL

Indicates scrolling along the horizontal axis.

Constant Value: 1 (0x00000001)

SCROLL_AXIS_NONE

added in version 22.1.0
int SCROLL_AXIS_NONE

Indicates no axis of view scrolling.

Constant Value: 0 (0x00000000)

SCROLL_AXIS_VERTICAL

added in version 22.1.0
int SCROLL_AXIS_VERTICAL

Indicates scrolling along the vertical axis.

Constant Value: 2 (0x00000002)

SCROLL_INDICATOR_BOTTOM

added in version 24.1.0
int SCROLL_INDICATOR_BOTTOM

Scroll indicator direction for the bottom edge of the view.

Constant Value: 2 (0x00000002)

SCROLL_INDICATOR_END

added in version 24.1.0
int SCROLL_INDICATOR_END

Scroll indicator direction for the ending edge of the view.

Constant Value: 32 (0x00000020)

SCROLL_INDICATOR_LEFT

added in version 24.1.0
int SCROLL_INDICATOR_LEFT

Scroll indicator direction for the left edge of the view.

Constant Value: 4 (0x00000004)

SCROLL_INDICATOR_RIGHT

added in version 24.1.0
int SCROLL_INDICATOR_RIGHT

Scroll indicator direction for the right edge of the view.

Constant Value: 8 (0x00000008)

SCROLL_INDICATOR_START

added in version 24.1.0
int SCROLL_INDICATOR_START

Scroll indicator direction for the starting edge of the view.

Constant Value: 16 (0x00000010)

SCROLL_INDICATOR_TOP

added in version 24.1.0
int SCROLL_INDICATOR_TOP

Scroll indicator direction for the top edge of the view.

Constant Value: 1 (0x00000001)

TYPE_NON_TOUCH

added in version 26.1.0
int TYPE_NON_TOUCH

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.

Constant Value: 1 (0x00000001)

TYPE_TOUCH

added in version 26.1.0
int TYPE_TOUCH

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

Constant Value: 0 (0x00000000)

Protected constructors

ViewCompat

added in version 22.1.0
ViewCompat ()

Public methods

addKeyboardNavigationClusters

added in version 26.1.0
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. Does nothing on API < 26.

Parameters
view View

views Collection: collection of keyboard navigation cluster roots found so far.

direction int: direction to look.

animate

added in version 22.1.0
ViewPropertyAnimatorCompat animate (View view)

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

Parameters
view View

Returns
ViewPropertyAnimatorCompat ViewPropertyAnimator The ViewPropertyAnimator associated with this View.

canScrollHorizontally

added in version 22.1.0
boolean canScrollHorizontally (View view, 
                int direction)

This method was deprecated in API level 26.1.0.
Use 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 int: Negative to check scrolling left, positive to check scrolling right.

Returns
boolean true if this view can be scrolled in the specified direction, false otherwise.

canScrollVertically

added in version 22.1.0
boolean canScrollVertically (View view, 
                int direction)

This method was deprecated in API level 26.1.0.
Use 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 int: Negative to check scrolling up, positive to check scrolling down.

Returns
boolean true if this view can be scrolled in the specified direction, false otherwise.

cancelDragAndDrop

added in version 24.1.0
void cancelDragAndDrop (View v)

Cancel the drag and drop operation.

Parameters
v View

combineMeasuredStates

added in version 22.1.0
int combineMeasuredStates (int curState, 
                int newState)

This method was deprecated in API level 26.1.0.
Use 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.

Returns
int Returns a new integer reflecting the combination of the two states.

dispatchApplyWindowInsets

added in version 22.1.0
WindowInsetsCompat dispatchApplyWindowInsets (View view, 
                WindowInsetsCompat insets)

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
view View

insets WindowInsetsCompat: Insets to apply