FileDocCategorySizeDatePackage
ViewCompat.javaAPI DocAndroid 5.1 API88642Thu Mar 12 22:22:56 GMT 2015android.support.v4.view

ViewCompat

public class ViewCompat extends Object
Helper for accessing features in {@link View} introduced after API level 4 in a backwards compatible fashion.

Fields Summary
private static final String
TAG
public static final int
OVER_SCROLL_ALWAYS
Always allow a user to over-scroll this view, provided it is a view that can scroll.
public static final int
OVER_SCROLL_IF_CONTENT_SCROLLS
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.
public static final int
OVER_SCROLL_NEVER
Never allow a user to over-scroll this view.
private static final long
FAKE_FRAME_TIME
public static final int
IMPORTANT_FOR_ACCESSIBILITY_AUTO
Automatically determine whether a view is important for accessibility.
public static final int
IMPORTANT_FOR_ACCESSIBILITY_YES
The view is important for accessibility.
public static final int
IMPORTANT_FOR_ACCESSIBILITY_NO
The view is not important for accessibility.
public static final int
IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
The view is not important for accessibility, nor are any of its descendant views.
public static final 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 {@link ViewCompat#setAccessibilityLiveRegion(View, int)}.

public static final int
ACCESSIBILITY_LIVE_REGION_POLITE
Live region mode specifying that accessibility services should announce changes to this view.

Use with {@link ViewCompat#setAccessibilityLiveRegion(View, int)}.

public static final 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 {@link ViewCompat#setAccessibilityLiveRegion(View, int)}.

public static final int
LAYER_TYPE_NONE
Indicates that the view does not have a layer.
public static final int
LAYER_TYPE_SOFTWARE

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.)

public static final int
LAYER_TYPE_HARDWARE

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 {@link #LAYER_TYPE_SOFTWARE 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.

public static final int
LAYOUT_DIRECTION_LTR
Horizontal layout direction of this view is from Left to Right.
public static final int
LAYOUT_DIRECTION_RTL
Horizontal layout direction of this view is from Right to Left.
public static final int
LAYOUT_DIRECTION_INHERIT
Horizontal layout direction of this view is inherited from its parent. Use with {@link #setLayoutDirection}.
public static final int
LAYOUT_DIRECTION_LOCALE
Horizontal layout direction of this view is from deduced from the default language script for the locale. Use with {@link #setLayoutDirection}.
public static final int
MEASURED_SIZE_MASK
Bits of {@link #getMeasuredWidthAndState} and {@link #getMeasuredWidthAndState} that provide the actual measured size.
public static final int
MEASURED_STATE_MASK
Bits of {@link #getMeasuredWidthAndState} and {@link #getMeasuredWidthAndState} that provide the additional state bits.
public static final int
MEASURED_HEIGHT_STATE_SHIFT
Bit shift of {@link #MEASURED_STATE_MASK} to get to the height bits for functions that combine both width and height into a single int, such as {@link #getMeasuredState} and the childState argument of {@link #resolveSizeAndState(int, int, int)}.
public static final int
MEASURED_STATE_TOO_SMALL
Bit of {@link #getMeasuredWidthAndState} and {@link #getMeasuredWidthAndState} that indicates the measured size is smaller that the space the view would like to have.
static final ViewCompatImpl
IMPL
Constructors Summary
Methods Summary
public static ViewPropertyAnimatorCompatanimate(android.view.View view)
This method returns a ViewPropertyAnimator object, which can be used to animate specific properties on this View.

Prior to API 14, this method will do nothing.

return
ViewPropertyAnimator The ViewPropertyAnimator associated with this View.

        return IMPL.animate(view);
    
public static booleancanScrollHorizontally(android.view.View v, int direction)
Check if this view can be scrolled horizontally in a certain direction.

param
v The View against which to invoke the method.
param
direction Negative to check scrolling left, positive to check scrolling right.
return
true if this view can be scrolled in the specified direction, false otherwise.

        final int version = android.os.Build.VERSION.SDK_INT;
        if (version >= 21) {
            IMPL = new Api21ViewCompatImpl();
        } else if (version >= 19) {
            IMPL = new KitKatViewCompatImpl();
        } else if (version >= 17) {
            IMPL = new JbMr1ViewCompatImpl();
        } else if (version >= 16) {
            IMPL = new JBViewCompatImpl();
        } else if (version >= 14) {
            IMPL = new ICSViewCompatImpl();
        } else if (version >= 11) {
            IMPL = new HCViewCompatImpl();
        } else if (version >= 9) {
            IMPL = new GBViewCompatImpl();
        } else if (version >= 7) {
            IMPL = new EclairMr1ViewCompatImpl();
        } else {
            IMPL = new BaseViewCompatImpl();
        }
    
        return IMPL.canScrollHorizontally(v, direction);
    
public static booleancanScrollVertically(android.view.View v, int direction)
Check if this view can be scrolled vertically in a certain direction.

param
v The View against which to invoke the method.
param
direction Negative to check scrolling up, positive to check scrolling down.
return
true if this view can be scrolled in the specified direction, false otherwise.

        return IMPL.canScrollVertically(v, direction);
    
public static voiddispatchFinishTemporaryDetach(android.view.View view)
Notify a view that its temporary detach has ended; the view is now reattached.

        IMPL.dispatchFinishTemporaryDetach(view);
    
public static voiddispatchStartTemporaryDetach(android.view.View view)
Notify a view that it is being temporarily detached.

        IMPL.dispatchStartTemporaryDetach(view);
    
public static intgetAccessibilityLiveRegion(android.view.View view)
Gets the live region mode for the specified View.

param
view The view from which to obtain the live region mode
return
The live region mode for the view.
see
ViewCompat#setAccessibilityLiveRegion(View, int)

        return IMPL.getAccessibilityLiveRegion(view);
    
public static android.support.v4.view.accessibility.AccessibilityNodeProviderCompatgetAccessibilityNodeProvider(android.view.View view)
Gets the provider for managing a virtual view hierarchy rooted at this View and reported to {@link android.accessibilityservice.AccessibilityService}s that explore the window content.

If this method returns an instance, this instance is responsible for managing {@link AccessibilityNodeInfoCompat}s 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 {@link AccessibilityDelegateCompat} has been specified via calling {@link #setAccessibilityDelegate(View, AccessibilityDelegateCompat)} its {@link AccessibilityDelegateCompat#getAccessibilityNodeProvider(View)} is responsible for handling this call.

param
view The view whose property to get.
return
The provider.
see
AccessibilityNodeProviderCompat

        return IMPL.getAccessibilityNodeProvider(view);
    
public static floatgetAlpha(android.view.View view)
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. Prior to API 11, the returned value is always 1.0f.

return
The opacity of the view.

        return IMPL.getAlpha(view);
    
public static floatgetElevation(android.view.View view)
The base elevation of this view relative to its parent, in pixels.

return
The base depth position of the view, in pixels.

        return IMPL.getElevation(view);
    
public static booleangetFitsSystemWindows(android.view.View v)
Returns true if this view should adapt to fit system window insets. This method will always return false before API 16 (Jellybean).

        return IMPL.getFitsSystemWindows(v);
    
public static intgetImportantForAccessibility(android.view.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.

param
view The view whose property to get.
return
The mode for determining whether a View is important for accessibility.
see
#IMPORTANT_FOR_ACCESSIBILITY_YES
see
#IMPORTANT_FOR_ACCESSIBILITY_NO
see
#IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
see
#IMPORTANT_FOR_ACCESSIBILITY_AUTO

        return IMPL.getImportantForAccessibility(view);
    
public static intgetLabelFor(android.view.View view)
Gets the id of a view for which a given view serves as a label for accessibility purposes.

param
view The view on which to invoke the corresponding method.
return
The labeled view id.

        return IMPL.getLabelFor(view);
    
public static intgetLayerType(android.view.View view)
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 {@link #LAYER_TYPE_NONE}. Refer to the documentation of {@link #setLayerType(android.view.View, int, android.graphics.Paint)} for more information on the different types of layers.

param
view The view to fetch the layer type from
return
{@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or {@link #LAYER_TYPE_HARDWARE}
see
#setLayerType(android.view.View, int, android.graphics.Paint)
see
#LAYER_TYPE_NONE
see
#LAYER_TYPE_SOFTWARE
see
#LAYER_TYPE_HARDWARE

        return IMPL.getLayerType(view);
    
public static intgetLayoutDirection(android.view.View view)
Returns the resolved layout direction for this view.

param
view View to get layout direction for
return
{@link #LAYOUT_DIRECTION_RTL} if the layout direction is RTL or returns {@link #LAYOUT_DIRECTION_LTR} if the layout direction is not RTL. For compatibility, this will return {@link #LAYOUT_DIRECTION_LTR} if API version is lower than Jellybean MR1 (API 17)

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

return
The measured width of this view as a bit mask.

        return IMPL.getMeasuredHeightAndState(view);
    
public static intgetMeasuredState(android.view.View view)
Return only the state bits of {@link #getMeasuredWidthAndState} and {@link #getMeasuredHeightAndState}, combined into one integer. The width component is in the regular bits {@link #MEASURED_STATE_MASK} and the height component is at the shifted bits {@link #MEASURED_HEIGHT_STATE_SHIFT}>>{@link #MEASURED_STATE_MASK}.

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

return
The measured width of this view as a bit mask.

        return IMPL.getMeasuredWidthAndState(view);
    
public static intgetMinimumHeight(android.view.View view)
Returns the minimum height of the view.

Prior to API 16 this will return 0.

return
the minimum height the view will try to be.

        return IMPL.getMinimumHeight(view);
    
public static intgetMinimumWidth(android.view.View view)
Returns the minimum width of the view.

Prior to API 16 this will return 0.

return
the minimum width the view will try to be.

        return IMPL.getMinimumWidth(view);
    
public static intgetOverScrollMode(android.view.View v)
Returns the over-scroll mode for this view. The result will be one of {@link #OVER_SCROLL_ALWAYS} (default), {@link #OVER_SCROLL_IF_CONTENT_SCROLLS} (allow over-scrolling only if the view content is larger than the container), or {@link #OVER_SCROLL_NEVER}.

param
v The View against which to invoke the method.
return
This view's over-scroll mode.

        return IMPL.getOverScrollMode(v);
    
public static intgetPaddingEnd(android.view.View view)
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.

param
view The view to get padding for
return
the end padding in pixels

        return IMPL.getPaddingEnd(view);
    
public static intgetPaddingStart(android.view.View view)
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.

param
view The view to get padding for
return
the start padding in pixels

        return IMPL.getPaddingStart(view);
    
public static android.view.ViewParentgetParentForAccessibility(android.view.View view)
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.

param
view View to retrieve parent for
return
The parent for use in accessibility inspection

        return IMPL.getParentForAccessibility(view);
    
public static floatgetPivotX(android.view.View view)
The x location of the point around which the view is {@link #setRotation(View, float) rotated} and {@link #setScaleX(View, float) scaled}.

Prior to API 11 this will have no effect.

        return IMPL.getPivotX(view);
    
public static floatgetPivotY(android.view.View view)
The y location of the point around which the view is {@link #setRotation(View, float) rotated} and {@link #setScaleY(View, float) scaled}.

Prior to API 11 this will return 0.

return
The y location of the pivot point.

        return IMPL.getPivotY(view);
    
public static floatgetRotation(android.view.View view)

        return IMPL.getRotation(view);
    
public static floatgetRotationX(android.view.View view)

        return IMPL.getRotationX(view);
    
public static floatgetRotationY(android.view.View view)

        return IMPL.getRotationY(view);
    
public static floatgetScaleX(android.view.View view)

        return IMPL.getScaleX(view);
    
public static floatgetScaleY(android.view.View view)

        return IMPL.getScaleY(view);
    
public static java.lang.StringgetTransitionName(android.view.View view)
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.

param
view The View against which to invoke the method.
return
The name used of the View to be used to identify Views in Transitions or null if no name has been given.

        return IMPL.getTransitionName(view);
    
public static floatgetTranslationX(android.view.View view)
The horizontal location of this view relative to its {@link View#getLeft() left} position. This position is post-layout, in addition to wherever the object's layout placed it.

Prior to API 11 this will return 0.

return
The horizontal position of this view relative to its left position, in pixels.

        return IMPL.getTranslationX(view);
    
public static floatgetTranslationY(android.view.View view)
The vertical location of this view relative to its {@link View#getTop() left} position. This position is post-layout, in addition to wherever the object's layout placed it.

Prior to API 11 this will return 0.

return
The vertical position of this view relative to its top position, in pixels.

        return IMPL.getTranslationY(view);
    
public static floatgetTranslationZ(android.view.View view)
The depth location of this view relative to its {@link #getElevation(View) elevation}.

return
The depth of this view relative to its elevation.

        return IMPL.getTranslationZ(view);
    
public static intgetWindowSystemUiVisibility(android.view.View view)
Returns the current system UI visibility that is currently set for the entire window.

        return IMPL.getWindowSystemUiVisibility(view);
    
public static floatgetX(android.view.View view)

        return IMPL.getX(view);
    
public static floatgetY(android.view.View view)

        return IMPL.getY(view);
    
public static booleanhasAccessibilityDelegate(android.view.View v)
Checks whether provided View has an accessibility delegate attached to it.

param
v The View instance to check
return
True if the View has an accessibility delegate

        return IMPL.hasAccessibilityDelegate(v);
    
public static booleanhasTransientState(android.view.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.

param
view View to check for transient state
return
true if the view has transient state

        return IMPL.hasTransientState(view);
    
public static booleanisOpaque(android.view.View view)
Indicates whether this View is opaque. An opaque View guarantees that it will draw all the pixels overlapping its bounds using a fully opaque color. On API 7 and above this will call View's true isOpaque method. On previous platform versions it will check the opacity of the view's background drawable if present.

return
True if this View is guaranteed to be fully opaque, false otherwise.

        return IMPL.isOpaque(view);
    
public static voidjumpDrawablesToCurrentState(android.view.View v)
On API 11 devices and above, call Drawable.jumpToCurrentState() on all Drawable objects associated with this view.

On API 21 and above, also calls StateListAnimator#jumpToCurrentState() if there is a StateListAnimator attached to this view.

        IMPL.jumpDrawablesToCurrentState(v);
    
public static voidonInitializeAccessibilityEvent(android.view.View v, android.view.accessibility.AccessibilityEvent event)
Initializes an {@link AccessibilityEvent} with information about this View which is the event source. In other words, the source of an accessibility event is the view whose state change triggered firing the event.

Example: Setting the password property of an event in addition to properties set by the super implementation:

 public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
super.onInitializeAccessibilityEvent(event);
event.setPassword(true);
}

If an {@link android.view.View.AccessibilityDelegate} has been specified via calling {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its {@link android.view.View.AccessibilityDelegate#onInitializeAccessibilityEvent(View, AccessibilityEvent)} is responsible for handling this call.

Note: Always call the super implementation before adding information to the event, in case the default implementation has basic information to add.

param
v The View against which to invoke the method.
param
event The event to initialize.
see
View#sendAccessibilityEvent(int)
see
View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)

        IMPL.onInitializeAccessibilityEvent(v, event);
    
public static voidonInitializeAccessibilityNodeInfo(android.view.View v, android.support.v4.view.accessibility.AccessibilityNodeInfoCompat info)
Initializes an {@link android.view.accessibility.AccessibilityNodeInfo} with information about this view. The base implementation sets:
  • {@link android.view.accessibility.AccessibilityNodeInfo#setParent(View)},
  • {@link android.view.accessibility.AccessibilityNodeInfo#setBoundsInParent(Rect)},
  • {@link android.view.accessibility.AccessibilityNodeInfo#setBoundsInScreen(Rect)},
  • {@link android.view.accessibility.AccessibilityNodeInfo#setPackageName(CharSequence)},
  • {@link android.view.accessibility.AccessibilityNodeInfo#setClassName(CharSequence)},
  • {@link android.view.accessibility.AccessibilityNodeInfo#setContentDescription(CharSequence)},
  • {@link android.view.accessibility.AccessibilityNodeInfo#setEnabled(boolean)},
  • {@link android.view.accessibility.AccessibilityNodeInfo#setClickable(boolean)},
  • {@link android.view.accessibility.AccessibilityNodeInfo#setFocusable(boolean)},
  • {@link android.view.accessibility.AccessibilityNodeInfo#setFocused(boolean)},
  • {@link android.view.accessibility.AccessibilityNodeInfo#setLongClickable(boolean)},
  • {@link android.view.accessibility.AccessibilityNodeInfo#setSelected(boolean)},

Subclasses should override this method, call the super implementation, and set additional attributes.

If an {@link android.view.View.AccessibilityDelegate} has been specified via calling {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its {@link android.view.View.AccessibilityDelegate#onInitializeAccessibilityNodeInfo(View, android.view.accessibility.AccessibilityNodeInfo)} is responsible for handling this call.

param
v The View against which to invoke the method.
param
info The instance to initialize.

        IMPL.onInitializeAccessibilityNodeInfo(v, info);
    
public static voidonPopulateAccessibilityEvent(android.view.View v, android.view.accessibility.AccessibilityEvent event)
Called from {@link View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)} giving a chance to this View to populate the accessibility event with its text content. While this method is free to modify event attributes other than text content, doing so should normally be performed in {@link View#onInitializeAccessibilityEvent(AccessibilityEvent)}.

Example: Adding formatted date string to an accessibility event in addition to the text added by the super implementation:

 public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
super.onPopulateAccessibilityEvent(event);
final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY;
String selectedDateUtterance = DateUtils.formatDateTime(mContext,
mCurrentDate.getTimeInMillis(), flags);
event.getText().add(selectedDateUtterance);
}

If an {@link android.view.View.AccessibilityDelegate} has been specified via calling {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its {@link android.view.View.AccessibilityDelegate#onPopulateAccessibilityEvent(View, AccessibilityEvent)} is responsible for handling this call.

Note: Always call the super implementation before adding information to the event, in case the default implementation has basic information to add.

param
v The View against which to invoke the method.
param
event The accessibility event which to populate.
see
View#sendAccessibilityEvent(int)
see
View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)

        IMPL.onPopulateAccessibilityEvent(v, event);
    
public static booleanperformAccessibilityAction(android.view.View view, int action, android.os.Bundle arguments)
Performs the specified accessibility action on the view. For possible accessibility actions look at {@link AccessibilityNodeInfoCompat}.

If an {@link AccessibilityDelegateCompat} has been specified via calling {@link #setAccessibilityDelegate(View, AccessibilityDelegateCompat)} its {@link AccessibilityDelegateCompat#performAccessibilityAction(View, int, Bundle)} is responsible for handling this call.

param
action The action to perform.
param
arguments Optional action arguments.
return
Whether the action was performed.

        return IMPL.performAccessibilityAction(view, action, arguments);
    
public static voidpostInvalidateOnAnimation(android.view.View view)

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

This method can be invoked from outside of the UI thread only when this View is attached to a window.

param
view View to invalidate

        IMPL.postInvalidateOnAnimation(view);
    
public static voidpostInvalidateOnAnimation(android.view.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.

This method can be invoked from outside of the UI thread only when this View is attached to a window.

param
view View to invalidate
param
left The left coordinate of the rectangle to invalidate.
param
top The top coordinate of the rectangle to invalidate.
param
right The right coordinate of the rectangle to invalidate.
param
bottom The bottom coordinate of the rectangle to invalidate.

        IMPL.postInvalidateOnAnimation(view, left, top, right, bottom);
    
public static voidpostOnAnimation(android.view.View view, java.lang.Runnable action)

Causes the Runnable to execute on the next animation time step. The runnable will be run on the user interface thread.

This method can be invoked from outside of the UI thread only when this View is attached to a window.

param
view View to post this Runnable to
param
action The Runnable that will be executed.

        IMPL.postOnAnimation(view, action);
    
public static voidpostOnAnimationDelayed(android.view.View view, java.lang.Runnable action, long delayMillis)

Causes the Runnable to execute on the next animation time step, after the specified amount of time elapses. The runnable will be run on the user interface thread.

This method can be invoked from outside of the UI thread only when this View is attached to a window.

param
view The view to post this Runnable to
param
action The Runnable that will be executed.
param
delayMillis The delay (in milliseconds) until the Runnable will be executed.

        IMPL.postOnAnimationDelayed(view, action, delayMillis);
    
public static voidrequestApplyInsets(android.view.View view)
Ask that a new dispatch of {@code View.onApplyWindowInsets(WindowInsets)} be performed. This falls back to {@code View.requestFitSystemWindows()} where available.

        IMPL.requestApplyInsets(view);
    
public static intresolveSizeAndState(int size, int measureSpec, int childMeasuredState)
Utility to reconcile a desired size and state, with constraints imposed by a MeasureSpec. Will take the desired size, unless a different size is imposed by the constraints. The returned value is a compound integer, with the resolved size in the {@link #MEASURED_SIZE_MASK} bits and optionally the bit {@link #MEASURED_STATE_TOO_SMALL} set if the resulting size is smaller than the size the view wants to be.

param
size How big the view wants to be
param
measureSpec Constraints imposed by the parent
return
Size information bit mask as defined by {@link #MEASURED_SIZE_MASK} and {@link #MEASURED_STATE_TOO_SMALL}.

        return IMPL.resolveSizeAndState(size, measureSpec, childMeasuredState);
    
public static voidsetAccessibilityDelegate(android.view.View v, AccessibilityDelegateCompat delegate)
Sets a delegate for implementing accessibility support via compositon as opposed to inheritance. The delegate's primary use is for implementing backwards compatible widgets. For more details see {@link android.view.View.AccessibilityDelegate}.

param
v The View against which to invoke the method.
param
delegate The delegate instance.
see
android.view.View.AccessibilityDelegate

        IMPL.setAccessibilityDelegate(v, delegate);
    
public static voidsetAccessibilityLiveRegion(android.view.View view, int mode)
Sets the live region mode for the specified view. This indicates to accessibility services whether they should automatically notify the user about changes to the view's content description or text, or to the content descriptions or text of the view's children (where applicable).

For example, in a login screen with a TextView that displays an "incorrect password" notification, that view should be marked as a live region with mode {@link #ACCESSIBILITY_LIVE_REGION_POLITE}.

To disable change notifications for this view, use {@link #ACCESSIBILITY_LIVE_REGION_NONE}. This is the default live region mode for most views.

To indicate that the user should be notified of changes, use {@link #ACCESSIBILITY_LIVE_REGION_POLITE}.

If the view's changes should interrupt ongoing speech and notify the user immediately, use {@link #ACCESSIBILITY_LIVE_REGION_ASSERTIVE}.

param
view The view on which to set the live region mode
param
mode The live region mode for this view, one of:
  • {@link #ACCESSIBILITY_LIVE_REGION_NONE}
  • {@link #ACCESSIBILITY_LIVE_REGION_POLITE}
  • {@link #ACCESSIBILITY_LIVE_REGION_ASSERTIVE}

        IMPL.setAccessibilityLiveRegion(view, mode);
    
public static voidsetActivated(android.view.View view, boolean activated)
Changes the activated state of this view. A view can be activated or not. Note that activation is not the same as selection. Selection is a transient property, representing the view (hierarchy) the user is currently interacting with. Activation is a longer-term state that the user can move views in and out of.

param
activated true if the view must be activated, false otherwise

        IMPL.setActivated(view, activated);
    
public static voidsetAlpha(android.view.View view, float value)

Sets 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.

Note that setting alpha to a translucent value (0 < alpha < 1) can have significant performance implications, especially for large views. It is best to use the alpha property sparingly and transiently, as in the case of fading animations.

Prior to API 11 this will have no effect.

param
value The opacity of the view.

        IMPL.setAlpha(view, value);
    
public static voidsetChildrenDrawingOrderEnabled(android.view.ViewGroup viewGroup, boolean enabled)
Tells the ViewGroup whether to draw its children in the order defined by the method {@code ViewGroup.getChildDrawingOrder(int, int)}.

param
enabled true if the order of the children when drawing is determined by {@link ViewGroup#getChildDrawingOrder(int, int)}, false otherwise

Prior to API 7 this will have no effect.

       IMPL.setChildrenDrawingOrderEnabled(viewGroup, enabled);
    
public static voidsetElevation(android.view.View view, float elevation)
Sets the base elevation of this view, in pixels.

        IMPL.setElevation(view, elevation);
    
public static voidsetFitsSystemWindows(android.view.View view, boolean fitSystemWindows)
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 {@link View#fitSystemWindows(Rect)} will be executed. See that method for more details.

        IMPL.setFitsSystemWindows(view, fitSystemWindows);
    
public static voidsetHasTransientState(android.view.View view, boolean hasTransientState)
Set whether this view is currently tracking transient state that the framework should attempt to preserve when possible.

param
view View tracking transient state
param
hasTransientState true if this view has transient state

        IMPL.setHasTransientState(view, hasTransientState);
    
public static voidsetImportantForAccessibility(android.view.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.

Note: If the current paltform version does not support the {@link #IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS} mode, then {@link #IMPORTANT_FOR_ACCESSIBILITY_NO} will be used as it is the closest terms of semantics.

param
view The view whose property to set.
param
mode How to determine whether this view is important for accessibility.
see
#IMPORTANT_FOR_ACCESSIBILITY_YES
see
#IMPORTANT_FOR_ACCESSIBILITY_NO
see
#IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
see
#IMPORTANT_FOR_ACCESSIBILITY_AUTO

        IMPL.setImportantForAccessibility(view, mode);
    
public static voidsetLabelFor(android.view.View view, int labeledId)
Sets the id of a view for which a given view serves as a label for accessibility purposes.

param
view The view on which to invoke the corresponding method.
param
labeledId The labeled view id.

        IMPL.setLabelFor(view, labeledId);
    
public static voidsetLayerPaint(android.view.View view, android.graphics.Paint paint)
Updates the {@link Paint} object used with the current layer (used only if the current layer type is not set to {@link #LAYER_TYPE_NONE}). Changed properties of the Paint provided to {@link #setLayerType(android.view.View, int, android.graphics.Paint)} will be used the next time the View is redrawn, but {@link #setLayerPaint(android.view.View, android.graphics.Paint)} must be called to ensure that the view gets redrawn immediately.

A layer is associated with an optional {@link android.graphics.Paint} instance that controls how the layer is composed on screen. The following properties of the paint are taken into account when composing the layer:

  • {@link android.graphics.Paint#getAlpha() Translucency (alpha)}
  • {@link android.graphics.Paint#getXfermode() Blending mode}
  • {@link android.graphics.Paint#getColorFilter() Color filter}

If this view has an alpha value set to < 1.0 by calling View#setAlpha(float), the alpha value of the layer's paint is replaced by this view's alpha value. Calling View#setAlpha(float) is therefore equivalent to setting a hardware layer on this view and providing a paint with the desired alpha value.

param
view View to set a layer paint for
param
paint The paint used to compose the layer. This argument is optional and can be null. It is ignored when the layer type is {@link #LAYER_TYPE_NONE}
see
#setLayerType(View, int, android.graphics.Paint)

        IMPL.setLayerPaint(view, paint);
    
public static voidsetLayerType(android.view.View view, int layerType, android.graphics.Paint paint)

Specifies the type of layer backing this view. The layer can be {@link #LAYER_TYPE_NONE disabled}, {@link #LAYER_TYPE_SOFTWARE software} or {@link #LAYER_TYPE_HARDWARE hardware}.

A layer is associated with an optional {@link android.graphics.Paint} instance that controls how the layer is composed on screen. The following properties of the paint are taken into account when composing the layer:

  • {@link android.graphics.Paint#getAlpha() Translucency (alpha)}
  • {@link android.graphics.Paint#getXfermode() Blending mode}
  • {@link android.graphics.Paint#getColorFilter() Color filter}

If this view has an alpha value set to < 1.0 by calling setAlpha(float), the alpha value of the layer's paint is replaced by this view's alpha value. Calling setAlpha(float) is therefore equivalent to setting a hardware layer on this view and providing a paint with the desired alpha value.

Refer to the documentation of {@link #LAYER_TYPE_NONE disabled}, {@link #LAYER_TYPE_SOFTWARE software} and {@link #LAYER_TYPE_HARDWARE hardware} for more information on when and how to use layers.

param
layerType The ype of layer to use with this view, must be one of {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or {@link #LAYER_TYPE_HARDWARE}
param
paint The paint used to compose the layer. This argument is optional and can be null. It is ignored when the layer type is {@link #LAYER_TYPE_NONE}
param
view View to set the layer type for
param
layerType The type of layer to use with this view, must be one of {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or {@link #LAYER_TYPE_HARDWARE}
param
paint The paint used to compose the layer. This argument is optional and can be null. It is ignored when the layer type is {@link #LAYER_TYPE_NONE}

        IMPL.setLayerType(view, layerType, paint);
    
public static voidsetLayoutDirection(android.view.View view, int layoutDirection)
Set the layout direction for this view. This will propagate a reset of layout direction resolution to the view's children and resolve layout direction for this view.

param
view View to set layout direction for
param
layoutDirection the layout direction to set. Should be one of: {@link #LAYOUT_DIRECTION_LTR}, {@link #LAYOUT_DIRECTION_RTL}, {@link #LAYOUT_DIRECTION_INHERIT}, {@link #LAYOUT_DIRECTION_LOCALE}. Resolution will be done if the value is set to LAYOUT_DIRECTION_INHERIT. The resolution proceeds up the parent chain of the view to get the value. If there is no parent, then it will return the default {@link #LAYOUT_DIRECTION_LTR}.

        IMPL.setLayoutDirection(view, layoutDirection);
    
public static voidsetOnApplyWindowInsetsListener(android.view.View v, OnApplyWindowInsetsListener listener)
Set an {@link OnApplyWindowInsetsListener} to take over the policy for applying window insets to this view. This will only take effect on devices with API 21 or above.

        IMPL.setOnApplyWindowInsetsListener(v, listener);
    
public static voidsetOverScrollMode(android.view.View v, int overScrollMode)
Set the over-scroll mode for this view. Valid over-scroll modes are {@link #OVER_SCROLL_ALWAYS} (default), {@link #OVER_SCROLL_IF_CONTENT_SCROLLS} (allow over-scrolling only if the view content is larger than the container), or {@link #OVER_SCROLL_NEVER}. Setting the over-scroll mode of a view will have an effect only if the view is capable of scrolling.

param
v The View against which to invoke the method.
param
overScrollMode The new over-scroll mode for this view.

        IMPL.setOverScrollMode(v, overScrollMode);
    
public static voidsetPaddingRelative(android.view.View view, int start, int top, int end, int bottom)
Sets the relative padding. The view may add on the space required to display the scrollbars, depending on the style and visibility of the scrollbars. So the values returned from {@link #getPaddingStart}, {@link View#getPaddingTop}, {@link #getPaddingEnd} and {@link View#getPaddingBottom} may be different from the values set in this call.

param
view The view on which to set relative padding
param
start the start padding in pixels
param
top the top padding in pixels
param
end the end padding in pixels
param
bottom the bottom padding in pixels

        IMPL.setPaddingRelative(view, start, top, end, bottom);
    
public static voidsetPivotX(android.view.View view, float value)
Sets the x location of the point around which the view is {@link #setRotation(View, float) rotated} and {@link #setScaleX(View, float) scaled}. By default, the pivot point is centered on the object. Setting this property disables this behavior and causes the view to use only the explicitly set pivotX and pivotY values.

Prior to API 11 this will have no effect.

param
value The x location of the pivot point.

        IMPL.setPivotX(view, value);
    
public static voidsetPivotY(android.view.View view, float value)
Sets the y location of the point around which the view is {@link #setRotation(View, float) rotated} and {@link #setScaleY(View, float) scaled}. By default, the pivot point is centered on the object. Setting this property disables this behavior and causes the view to use only the explicitly set pivotX and pivotY values.

Prior to API 11 this will have no effect.

param
value The y location of the pivot point.

        IMPL.setPivotX(view, value);
    
public static voidsetRotation(android.view.View view, float value)
Sets the degrees that the view is rotated around the pivot point. Increasing values result in clockwise rotation.

Prior to API 11 this will have no effect.

param
value The degrees of rotation.

        IMPL.setRotation(view, value);
    
public static voidsetRotationX(android.view.View view, float value)
Sets the degrees that the view is rotated around the horizontal axis through the pivot point. Increasing values result in clockwise rotation from the viewpoint of looking down the x axis.

Prior to API 11 this will have no effect.

param
value The degrees of X rotation.

        IMPL.setRotationX(view, value);
    
public static voidsetRotationY(android.view.View view, float value)
Sets the degrees that the view is rotated around the vertical axis through the pivot point. Increasing values result in counter-clockwise rotation from the viewpoint of looking down the y axis.

Prior to API 11 this will have no effect.

param
value The degrees of Y rotation.

        IMPL.setRotationY(view, value);
    
public static voidsetSaveFromParentEnabled(android.view.View v, boolean enabled)
Controls whether the entire hierarchy under this view will save its state when a state saving traversal occurs from its parent.

param
enabled Set to false to disable state saving, or true (the default) to allow it.

        IMPL.setSaveFromParentEnabled(v, enabled);
    
public static voidsetScaleX(android.view.View view, float value)
Sets the amount that the view is scaled in x around the pivot point, as a proportion of the view's unscaled width. A value of 1 means that no scaling is applied.

Prior to API 11 this will have no effect.

param
value The scaling factor.

        IMPL.setScaleX(view, value);
    
public static voidsetScaleY(android.view.View view, float value)
Sets the amount that the view is scaled in Y around the pivot point, as a proportion of the view's unscaled width. A value of 1 means that no scaling is applied.

Prior to API 11 this will have no effect.

param
value The scaling factor.

        IMPL.setScaleY(view, value);
    
public static voidsetTransitionName(android.view.View view, java.lang.String transitionName)
Sets the name of the View to be used to identify Views in Transitions. Names should be unique in the View hierarchy.

param
view The View against which to invoke the method.
param
transitionName The name of the View to uniquely identify it for Transitions.

        IMPL.setTransitionName(view, transitionName);
    
public static voidsetTranslationX(android.view.View view, float value)
Sets the horizontal location of this view relative to its left position. This effectively positions the object post-layout, in addition to wherever the object's layout placed it.

Prior to API 11 this will have no effect.

param
value The horizontal position of this view relative to its left position, in pixels.

        IMPL.setTranslationX(view, value);
    
public static voidsetTranslationY(android.view.View view, float value)
Sets the vertical location of this view relative to its top position. This effectively positions the object post-layout, in addition to wherever the object's layout placed it.

Prior to API 11 this will have no effect.

param
value The vertical position of this view relative to its top position, in pixels.
attr
ref android.R.styleable#View_translationY

        IMPL.setTranslationY(view, value);
    
public static voidsetTranslationZ(android.view.View view, float translationZ)
Sets the depth location of this view relative to its {@link #getElevation(View) elevation}.

        IMPL.setTranslationZ(view, translationZ);
    
public static voidsetX(android.view.View view, float value)
Sets the visual x position of this view, in pixels. This is equivalent to setting the {@link #setTranslationX(View, float) translationX} property to be the difference between the x value passed in and the current left property of the view as determined by the layout bounds.

Prior to API 11 this will have no effect.

param
value The visual x position of this view, in pixels.

        IMPL.setX(view, value);
    
public static voidsetY(android.view.View view, float value)
Sets the visual y position of this view, in pixels. This is equivalent to setting the {@link #setTranslationY(View, float) translationY} property to be the difference between the y value passed in and the current top property of the view as determined by the layout bounds.

Prior to API 11 this will have no effect.

param
value The visual y position of this view, in pixels.

        IMPL.setY(view, value);