Package 

Class ViewCompat

    • Method Detail

      • saveAttributeDataForStyleable

         static void saveAttributeDataForStyleable(@NonNull() View view, @NonNull() Context context, @NonNull() Array<int> styleable, @Nullable() AttributeSet attrs, @NonNull() TypedArray t, int defStyleAttr, int defStyleRes)

        Stores debugging information about attributes. This should be called in a constructor byevery custom View that uses a custom styleable. If the custom view does not call it,then the custom attributes used by this view will not be visible in layout inspection tools.No-op before API 29.

        Parameters:
        context - Context under which this view is created.
        styleable - A reference to styleable array R.styleable.
        attrs - AttributeSet used to construct this view.
        t - Resolved TypedArray returned by a call toobtainAttributes.
        defStyleAttr - Default style attribute passed into the view constructor.
        defStyleRes - Default style resource passed into the view constructor.
      • canScrollHorizontally

        @Deprecated() static boolean canScrollHorizontally(View view, int direction)

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

        Parameters:
        view - The View against which to invoke the method.
        direction - Negative to check scrolling left, positive to check scrolling right.
      • canScrollVertically

        @Deprecated() static boolean canScrollVertically(View view, int direction)

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

        Parameters:
        view - The View against which to invoke the method.
        direction - Negative to check scrolling up, positive to check scrolling down.
      • setOverScrollMode

        @Deprecated() static void setOverScrollMode(View v, int overScrollMode)

        Set the over-scroll mode for this view. Valid over-scroll modes are OVER_SCROLL_ALWAYS (default), OVER_SCROLL_IF_CONTENT_SCROLLS (allow over-scrolling only if the view content is larger than the container),or OVER_SCROLL_NEVER.Setting the over-scroll mode of a view will have an effect only if theview is capable of scrolling.

        Parameters:
        v - The View against which to invoke the method.
        overScrollMode - The new over-scroll mode for this view.
      • isImportantForAutofill

         static boolean isImportantForAutofill(@NonNull() View v)

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

        Generally speaking, a view is important for autofill if:

        • The view can be autofilled by an android.service.autofill.AutofillService.
        • The view contents can help an android.service.autofill.AutofillService determine how other views can be autofilled.
          • For example, view containers should typically return {@code false} for performance reasons(since the important info is provided by their children), but if its properties have relevantinformation (for example, a resource id called {@code credentials}, it should return {@code true}. On the other hand, views representing labels or editable fields shouldtypically return {@code true}, but in some cases they could return {@code false} (for example, if they're part of a "Captcha" mechanism).

          • The value returned by this method depends on the value returned by getImportantForAutofill:

          • When a view is considered important for autofill:

          • On the other hand, when a view is considered not important for autofill:

          • This method is only supported on API >= 26.On API 25 and below, it will always return {@code true}.

      • hasTransientState

         static boolean hasTransientState(@NonNull() View view)

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

        Parameters:
        view - View to check for transient state
      • setHasTransientState

         static void setHasTransientState(@NonNull() View view, boolean hasTransientState)

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

        Parameters:
        view - View tracking transient state
        hasTransientState - true if this view has transient state
      • postInvalidateOnAnimation

         static void postInvalidateOnAnimation(@NonNull() View view)

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

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

        Parameters:
        view - View to invalidate
      • postInvalidateOnAnimation

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

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

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

        Parameters:
        view - View to invalidate
        left - The left coordinate of the rectangle to invalidate.
        top - The top coordinate of the rectangle to invalidate.
        right - The right coordinate of the rectangle to invalidate.
        bottom - The bottom coordinate of the rectangle to invalidate.
      • postOnAnimation

         static void postOnAnimation(@NonNull() View view, 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 threadonly when this View is attached to a window.

        Parameters:
        view - View to post this Runnable to
        action - The Runnable that will be executed.
      • postOnAnimationDelayed

         static void postOnAnimationDelayed(@NonNull() View view, 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 threadonly when this View is attached to a window.

        Parameters:
        view - The view to post this Runnable to
        action - The Runnable that will be executed.
        delayMillis - The delay (in milliseconds) until the Runnablewill be executed.
      • getAlpha

        @Deprecated() static float getAlpha(View view)

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

        By default this is 1.0f.

      • setLayerType

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

        Specifies the type of layer backing this view. The layer can be disabled, software or hardware.

        A layer is associated with an optional Paint instance that controls how the layer is composed on screen. The followingproperties of the paint are taken into account when composing the layer:

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

        Refer to the documentation of disabled, software and hardware for more information on when and how to use layers.

        Parameters:
        view - View to set the layer type for
        layerType - The type of layer to use with this view, must be one ofLAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE orLAYER_TYPE_HARDWARE
        paint - The paint used to compose the layer.
      • getLayerType

        @Deprecated() static int getLayerType(View view)

        Indicates what type of layer is currently associated with this view. By defaulta view does not have a layer, and the layer type is LAYER_TYPE_NONE.Refer to the documentation of setLayerType for more information on the different types of layers.

        Parameters:
        view - The view to fetch the layer type from
      • setLayerPaint

         static void setLayerPaint(@NonNull() View view, Paint paint)

        Updates the Paint object used with the current layer (used only if the currentlayer type is not set to LAYER_TYPE_NONE). Changed properties of the Paintprovided to setLayerType will be used the next time the View is redrawn, but setLayerPaint must be called to ensure that the view gets redrawn immediately.

        A layer is associated with an optional Paint instance that controls how the layer is composed on screen. The followingproperties of the paint are taken into account when composing the layer:

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

        Parameters:
        view - View to set a layer paint for
        paint - The paint used to compose the layer.
      • getLayoutDirection

         static int getLayoutDirection(@NonNull() View view)

        Returns the resolved layout direction for this view.

        Parameters:
        view - View to get layout direction for
      • setLayoutDirection

         static void setLayoutDirection(@NonNull() View view, int layoutDirection)

        Set the layout direction for this view. This will propagate a reset of layout directionresolution to the view's children and resolve layout direction for this view.

        Parameters:
        view - View to set layout direction for
        layoutDirection - the layout direction to set.
      • requireViewById

        @NonNull() static <T extends View> T requireViewById(@NonNull() View view, @IdRes() 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 thereis no matching view in the hierarchy.

        Note: In most cases -- depending on compiler support --the resulting view is automatically cast to the target class type. Ifthe target class type is unconstrained, an explicit cast may benecessary.

        Parameters:
        id - the ID to search for
      • isOpaque

        @Deprecated() static boolean isOpaque(View view)

        Indicates whether this View is opaque. An opaque View guarantees that it willdraw all the pixels overlapping its bounds using a fully opaque color.

      • resolveSizeAndState

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

        Utility to reconcile a desired size and state, with constraints imposedby a MeasureSpec. Will take the desired size, unless a different sizeis imposed by the constraints. The returned value is a compound integer,with the resolved size in the MEASURED_SIZE_MASK bits andoptionally the bit MEASURED_STATE_TOO_SMALL set if the resultingsize is smaller than the size the view wants to be.

        Parameters:
        size - How big the view wants to be
        measureSpec - Constraints imposed by the parent
      • combineMeasuredStates

        @Deprecated() static int combineMeasuredStates(int curState, int newState)

        Merge two states as returned by getMeasuredState.

        Parameters:
        curState - The current state as returned from a view or the resultof combining multiple views.
        newState - The new view state to combine.
      • getPaddingStart

        @Px() static int getPaddingStart(@NonNull() 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 spacerequired to display the scrollbars as well.

        Parameters:
        view - The view to get padding for
      • getPaddingEnd

        @Px() static int getPaddingEnd(@NonNull() 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 spacerequired to display the scrollbars as well.

        Parameters:
        view - The view to get padding for
      • setPaddingRelative

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

        Sets the relative padding. The view may add on the space required to displaythe scrollbars, depending on the style and visibility of the scrollbars.So the values returned from getPaddingStart, getPaddingTop, getPaddingEnd and getPaddingBottom may be differentfrom the values set in this call.

        Parameters:
        view - The view on which to set relative padding
        start - the start padding in pixels
        top - the top padding in pixels
        end - the end padding in pixels
        bottom - the bottom padding in pixels
      • getTranslationX

        @Deprecated() static float getTranslationX(View view)

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

      • getTranslationY

        @Deprecated() static float getTranslationY(View view)

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

      • getMatrix

        @Deprecated()@Nullable() static Matrix getMatrix(View view)

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

        Parameters:
        view - The view whose Matrix will be returned
      • getMinimumWidth

         static int getMinimumWidth(@NonNull() View view)

        Returns the minimum width of the view.

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

      • getMinimumHeight

         static int getMinimumHeight(@NonNull() View view)

        Returns the minimum height of the view.

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

      • setTranslationX

        @Deprecated() static void setTranslationX(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'slayout placed it.

        Parameters:
        value - The horizontal position of this view relative to its left position,in pixels.
      • setTranslationY

        @Deprecated() static void setTranslationY(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'slayout placed it.

        Parameters:
        value - The vertical position of this view relative to its top position,in pixels.
      • setAlpha

        @Deprecated() static void setAlpha(View view, @FloatRange(from = 0.0, to = 1.0) float value)

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

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

        Parameters:
        value - The opacity of the view.
      • setX

        @Deprecated() static void setX(View view, float value)

        Sets the visual x position of this view, in pixels. This is equivalent to setting the translationX property to be the difference betweenthe x value passed in and the current left property of the view as determinedby the layout bounds.

        Parameters:
        value - The visual x position of this view, in pixels.
      • setY

        @Deprecated() static void setY(View view, float value)

        Sets the visual y position of this view, in pixels. This is equivalent to setting the translationY property to be the difference betweenthe y value passed in and the current top property of the view as determined by thelayout bounds.

        Parameters:
        value - The visual y position of this view, in pixels.
      • setRotation

        @Deprecated() static void setRotation(View view, float value)

        Sets the degrees that the view is rotated around the pivot point. Increasing valuesresult in clockwise rotation.

        Parameters:
        value - The degrees of rotation.
      • setRotationX

        @Deprecated() static void setRotationX(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 thex axis.

        Parameters:
        value - The degrees of X rotation.
      • setRotationY

        @Deprecated() static void setRotationY(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 lookingdown the y axis.

        Parameters:
        value - The degrees of Y rotation.
      • setScaleX

        @Deprecated() static void setScaleX(View view, float value)

        Sets the amount that the view is scaled in x around the pivot point, as a proportion ofthe view's unscaled width. A value of 1 means that no scaling is applied.

        Parameters:
        value - The scaling factor.
      • setScaleY

        @Deprecated() static void setScaleY(View view, float value)

        Sets the amount that the view is scaled in Y around the pivot point, as a proportion ofthe view's unscaled width. A value of 1 means that no scaling is applied.

        Parameters:
        value - The scaling factor.
      • setPivotX

        @Deprecated() static void setPivotX(View view, float value)

        Sets the x location of the point around which the view is rotated and scaled.By default, the pivot point is centered on the object.Setting this property disables this behavior and causes the view to use only theexplicitly set pivotX and pivotY values.

        Parameters:
        value - The x location of the pivot point.
      • setPivotY

        @Deprecated() static void setPivotY(View view, float value)

        Sets the y location of the point around which the view is rotated and scaled.By default, the pivot point is centered on the object.Setting this property disables this behavior and causes the view to use only theexplicitly set pivotX and pivotY values.

        Parameters:
        value - The y location of the pivot point.
      • setElevation

         static void setElevation(@NonNull() View view, float elevation)

        Sets the base elevation of this view, in pixels.

      • getElevation

         static float getElevation(@NonNull() View view)

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

      • setTransitionName

         static void setTransitionName(@NonNull() View view, String transitionName)

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

        Parameters:
        view - The View against which to invoke the method.
        transitionName - The name of the View to uniquely identify it for Transitions.
      • getTransitionName

        @Nullable() static String getTransitionName(@NonNull() 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.

        Parameters:
        view - The View against which to invoke the method.
      • requestApplyInsets

         static void requestApplyInsets(@NonNull() View view)

        Ask that a new dispatch of {@code View.onApplyWindowInsets(WindowInsets)} be performed. Thisfalls back to {@code View.requestFitSystemWindows()} where available.

      • setChildrenDrawingOrderEnabled

        @Deprecated() static void setChildrenDrawingOrderEnabled(ViewGroup viewGroup, boolean enabled)

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

        Parameters:
        enabled - true if the order of the children when drawing is determined bygetChildDrawingOrder, false otherwisePrior to API 7 this will have no effect.
      • getFitsSystemWindows

         static boolean getFitsSystemWindows(@NonNull() View v)

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

      • setFitsSystemWindows

        @Deprecated() static void setFitsSystemWindows(View view, boolean fitSystemWindows)

        Sets whether or not this view should account for system screen decorationssuch as the status bar and inset its content; that is, controlling whetherthe default implementation of fitSystemWindows will beexecuted. See that method for more details.

      • jumpDrawablesToCurrentState

        @Deprecated() static void jumpDrawablesToCurrentState(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.

      • dispatchApplyWindowInsets

        @NonNull() static WindowInsetsCompat dispatchApplyWindowInsets(@NonNull() View view, @NonNull() 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 areasobscured 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 itschildren.

        Parameters:
        insets - Insets to apply
      • setSystemGestureExclusionRects

         static void setSystemGestureExclusionRects(@NonNull() View view, @NonNull() List<Rect> rects)

        Sets a list of areas within this view's post-layout coordinate space where the systemshould not intercept touch or other pointing device gestures. This method shouldbe called by onLayout or onDraw.

        On devices running API 28 and below, this method has no effect.

        Parameters:
        rects - A list of precision gesture regions that this view needs to function correctly
      • getSystemGestureExclusionRects

        @NonNull() static List<Rect> getSystemGestureExclusionRects(@NonNull() View view)

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

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

      • setSaveFromParentEnabled

        @Deprecated() static void setSaveFromParentEnabled(View v, boolean enabled)

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

        Parameters:
        enabled - Set to false to disable state saving, or true(the default) to allow it.
      • setActivated

        @Deprecated() static void setActivated(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 isa transient property, representing the view (hierarchy) the user iscurrently interacting with. Activation is a longer-term state that theuser can move views in and out of.

        Parameters:
        activated - true if the view must be activated, false otherwise
      • hasOverlappingRendering

         static boolean hasOverlappingRendering(@NonNull() View view)

        Returns whether this View has content which overlaps.

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

      • isPaddingRelative

         static boolean isPaddingRelative(@NonNull() View view)

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

      • setBackground

         static void setBackground(@NonNull() View view, @Nullable() Drawable background)

        Set the background of the {@code view} to a given Drawable, or remove the background. If thebackground has padding, {@code view}'s padding is set to the background's padding. However,when a background is removed, this View's padding isn't touched. If setting the padding isdesired, please use{@code setPadding(int, int, int, int)}.

      • getBackgroundTintList

         static ColorStateList getBackgroundTintList(@NonNull() View view)

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

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

      • setBackgroundTintList

         static void setBackgroundTintList(@NonNull() View view, ColorStateList tintList)

        Applies a tint to the background drawable.

        This will always take effect when running on API v21 or newer. When running on platformsprevious to API v21, it will only take effect if {@code view} implements the {@code TintableBackgroundView} interface.

      • getBackgroundTintMode

         static PorterDuff.Mode getBackgroundTintMode(@NonNull() View view)

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

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

      • setBackgroundTintMode

         static void setBackgroundTintMode(@NonNull() View view, PorterDuff.Mode mode)

        Specifies the blending mode used to apply the tint specified by setBackgroundTintList tothe background drawable. The default mode is SRC_IN.

        This will always take effect when running on API v21 or newer. When running on platformsprevious to API v21, it will only take effect if {@code view} implement the {@code TintableBackgroundView} interface.

      • setNestedScrollingEnabled

         static void setNestedScrollingEnabled(@NonNull() View view, boolean enabled)

        Enable or disable nested scrolling for this view.

        If this property is set to true the view will be permitted to initiate nestedscrolling operations with a compatible parent view in the current hierarchy. If thisview does not implement nested scrolling this will have no effect. Disabling nested scrollingwhile a nested scroll is in progress has the effect of stopping the nested scroll.

        Parameters:
        enabled - true to enable nested scrolling, false to disable
      • isNestedScrollingEnabled

         static boolean isNestedScrollingEnabled(@NonNull() View view)

        Returns true if nested scrolling is enabled for this view.

        If nested scrolling is enabled and this View class implementation supports it,this view will act as a nested scrolling child view when applicable, forwarding dataabout the scroll operation in progress to a compatible and cooperating nested scrollingparent.

      • dispatchNestedScroll

         static boolean dispatchNestedScroll(@NonNull() View view, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, @Nullable() Array<int> offsetInWindow)

        Dispatch one step of a nested scroll in progress.

        This version of the method just calls dispatchNestedScroll using the touch inputtype.

        Parameters:
        dxConsumed - Horizontal distance in pixels consumed by this view during this scroll step
        dyConsumed - Vertical distance in pixels consumed by this view during this scroll step
        dxUnconsumed - Horizontal scroll distance in pixels not consumed by this view
        dyUnconsumed - Horizontal scroll distance in pixels not consumed by this view
        offsetInWindow - Optional.
      • dispatchNestedPreScroll

         static boolean dispatchNestedPreScroll(@NonNull() View view, int dx, int dy, @Nullable() Array<int> consumed, @Nullable() Array<int> offsetInWindow)

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

        This version of the method just calls dispatchNestedPreScroll using the touch inputtype.

        Parameters:
        dx - Horizontal scroll distance in pixels
        dy - Vertical scroll distance in pixels
        consumed - Output.
        offsetInWindow - Optional.
      • startNestedScroll

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

        Begin a nestable scroll operation along the given axes.

        A view starting a nested scroll promises to abide by the following contract:

        The view will call startNestedScroll upon initiating a scroll operation. In the caseof a touch scroll this corresponds to the initial ACTION_DOWN.In the case of touch scrolling the nested scroll will be terminated automatically inthe same manner as requestDisallowInterceptTouchEvent.In the event of programmatic scrolling the caller must explicitly call stopNestedScroll to indicate the end of the nested scroll.

        If startNestedScroll returns true, a cooperative parent was found.If it returns false the caller may ignore the rest of this contract until the next scroll.Calling startNestedScroll while a nested scroll is already in progress will return true.

        At each incremental step of the scroll the caller should invoke dispatchNestedPreScroll once it has calculated the requested scrolling delta. If it returns true the nested scrollingparent at least partially consumed the scroll and the caller should adjust the amount itscrolls by.

        After applying the remainder of the scroll delta the caller should invoke dispatchNestedScroll, passingboth the delta consumed and the delta unconsumed. A nested scrolling parent may treatthese values differently. See onNestedScroll.

        Parameters:
        axes - Flags consisting of a combination of SCROLL_AXIS_HORIZONTAL and/or SCROLL_AXIS_VERTICAL.
        type - the type of input which cause this scroll event
      • stopNestedScroll

         static void stopNestedScroll(@NonNull() View view, int type)

        Stop a nested scroll in progress.

        Calling this method when a nested scroll is not currently in progress is harmless.

        Parameters:
        type - the type of input which cause this scroll event
      • hasNestedScrollingParent

         static boolean hasNestedScrollingParent(@NonNull() View view, int type)

        Returns true if this view has a nested scrolling parent.

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

        Parameters:
        type - the type of input which cause this scroll event
      • dispatchNestedScroll

         static void dispatchNestedScroll(@NonNull() View view, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, @Nullable() Array<int> offsetInWindow, int type, @NonNull() Array<int> consumed)

        Dispatch one step of a nested scroll in progress.

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

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

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

        Parameters:
        dxConsumed - Horizontal distance in pixels consumed by this view during this scroll step
        dyConsumed - Vertical distance in pixels consumed by this view during this scroll step
        dxUnconsumed - Horizontal scroll distance in pixels not consumed by this view
        dyUnconsumed - Horizontal scroll distance in pixels not consumed by this view
        offsetInWindow - Optional.
        type - the type of input which cause this scroll event
        consumed - Output, If not null, consumed[0] will contain the consumedcomponent of dx and consumed[1] the consumed dy.
      • dispatchNestedScroll

         static boolean dispatchNestedScroll(@NonNull() View view, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, @Nullable() Array<int> offsetInWindow, int type)

        Dispatch one step of a nested scroll in progress.

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

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

        Parameters:
        dxConsumed - Horizontal distance in pixels consumed by this view during this scroll step
        dyConsumed - Vertical distance in pixels consumed by this view during this scroll step
        dxUnconsumed - Horizontal scroll distance in pixels not consumed by this view
        dyUnconsumed - Horizontal scroll distance in pixels not consumed by this view
        offsetInWindow - Optional.
        type - the type of input which cause this scroll event
      • dispatchNestedPreScroll

         static boolean dispatchNestedPreScroll(@NonNull() View view, int dx, int dy, @Nullable() Array<int> consumed, @Nullable() Array<int> offsetInWindow, int type)

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

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

        Parameters:
        dx - Horizontal scroll distance in pixels
        dy - Vertical scroll distance in pixels
        consumed - Output.
        offsetInWindow - Optional.
        type - the type of input which cause this scroll event
      • dispatchNestedFling

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

        Dispatch a fling to a nested scrolling parent.

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

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

        Parameters:
        velocityX - Horizontal fling velocity in pixels per second
        velocityY - Vertical fling velocity in pixels per second
        consumed - true if the child consumed the fling, false otherwise
      • dispatchNestedPreFling

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

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

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

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

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

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

        Parameters:
        velocityX - Horizontal fling velocity in pixels per second
        velocityY - Vertical fling velocity in pixels per second
      • isInLayout

         static boolean isInLayout(@NonNull() View view)

        Returns whether the view hierarchy is currently undergoing a layout pass. Thisinformation is useful to avoid situations such as calling requestLayout during a layout pass.

        Compatibility:

        • API < 18: Always returns {@code false}
      • isLaidOut

         static boolean isLaidOut(@NonNull() View view)

        Returns true if {@code view} has been through at least one layout since itwas last attached to or detached from a window.

      • isLayoutDirectionResolved

         static boolean isLayoutDirectionResolved(@NonNull() View view)

        Returns whether layout direction has been resolved.

        Compatibility:

        • API < 19: Always returns {@code false}
      • getZ

         static float getZ(@NonNull() View view)

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

      • setZ

         static void setZ(@NonNull() View view, float z)

        Sets the visual z position of this view, in pixels. This is equivalent to setting the translationZ property to be the difference betweenthe x value passed in and the current elevation property.

        Compatibility:

        • API < 21: No-op
        Parameters:
        z - The visual z position of this view, in pixels.
      • offsetTopAndBottom

         static void offsetTopAndBottom(@NonNull() View view, int offset)

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

        Parameters:
        offset - the number of pixels to offset the view by
      • offsetLeftAndRight

         static void offsetLeftAndRight(@NonNull() View view, int offset)

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

        Parameters:
        offset - the number of pixels to offset the view by
      • setClipBounds

         static void setClipBounds(@NonNull() View view, Rect clipBounds)

        Sets a rectangular area on this view to which the view will be clippedwhen it is drawn. Setting the value to null will remove the clip boundsand the view will draw normally, using its full bounds.

        Prior to API 18 this does nothing.

        Parameters:
        view - The view to set clipBounds.
        clipBounds - The rectangular area, in the local coordinates ofthis view, to which future drawing operations will be clipped.
      • isAttachedToWindow

         static boolean isAttachedToWindow(@NonNull() View view)

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

      • setScrollIndicators

         static void setScrollIndicators(@NonNull() View view, int indicators)

        Sets the state of all scroll indicators.

        See setScrollIndicators for usage information.

        Parameters:
        indicators - a bitmask of indicators that should be enabled, or{@code 0} to disable all indicators
      • setScrollIndicators

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

        Sets the state of the scroll indicators specified by the mask. To changeall scroll indicators at once, see setScrollIndicators.

        When a scroll indicator is enabled, it will be displayed if the viewcan scroll in the direction of the indicator.

        Multiple indicator types may be enabled or disabled by passing thelogical OR of the desired types. If multiple types are specified, theywill all be set to the same enabled state.

        For example, to enable the top scroll indicatorExample: {@code setScrollIndicators}

        Parameters:
        indicators - the indicator direction, or the logical OR of multipleindicator directions.
      • getScrollIndicators

         static int getScrollIndicators(@NonNull() View view)

        Returns a bitmask representing the enabled scroll indicators.

        For example, if the top and left scroll indicators are enabled and allother indicators are disabled, the return value will be {@code ViewCompat.SCROLL_INDICATOR_TOP | ViewCompat.SCROLL_INDICATOR_LEFT}.

        To check whether the bottom scroll indicator is enabled, use the valueof {@code (ViewCompat.getScrollIndicators(view) & ViewCompat.SCROLL_INDICATOR_BOTTOM) != 0}.

      • setPointerIcon

         static void setPointerIcon(@NonNull() View view, PointerIconCompat pointerIcon)

        Set the pointer icon for the current view.

        Parameters:
        pointerIcon - A PointerIconCompat instance which will be shown when the mouse hovers.
      • getDisplay

        @Nullable() static Display getDisplay(@NonNull() View view)

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

        Compatibility:

        • API < 17: Returns the default display when the view is attached. Otherwise, null.
      • setTooltipText

         static void setTooltipText(@NonNull() View view, @Nullable() CharSequence tooltipText)

        Sets the tooltip for the view.

        Prior to API 26 this does nothing. Use TooltipCompat class from v7 appcompat libraryfor a compatible tooltip implementation.

        Parameters:
        tooltipText - the tooltip text
      • setNextClusterForwardId

         static void setNextClusterForwardId(@NonNull() View view, int nextClusterForwardId)

        Sets the ID of the next keyboard navigation cluster root view. Does nothing if {@code view} is not a keyboard navigation cluster or if API < 26.

        Parameters:
        nextClusterForwardId - next cluster ID, or NO_ID if the frameworkshould decide automatically.
      • isKeyboardNavigationCluster

         static boolean isKeyboardNavigationCluster(@NonNull() View view)

        Returns whether {@code view} is a root of a keyboard navigation cluster. Always returns {@code false} on API < 26.

      • setKeyboardNavigationCluster

         static void setKeyboardNavigationCluster(@NonNull() View view, boolean isCluster)

        Set whether {@code view} is a root of a keyboard navigation cluster. Does nothing ifAPI < 26.

        Parameters:
        isCluster - {@code true} to mark {@code view} as the root of a cluster, {@code false} to unmark.
      • isFocusedByDefault

         static boolean isFocusedByDefault(@NonNull() View view)

        Returns whether {@code view} should receive focus when the focus is restored for the viewhierarchy containing it. Returns {@code false} on API < 26.

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

      • setFocusedByDefault

         static void setFocusedByDefault(@NonNull() View view, boolean isFocusedByDefault)

        Sets whether {@code view} should receive focus when the focus is restored for the viewhierarchy containing it.

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

        Does nothing on API < 26.

        Parameters:
        isFocusedByDefault - {@code true} to set {@code view} as the default-focus view,{@code false} otherwise.
      • keyboardNavigationClusterSearch

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

        Find the nearest keyboard navigation cluster in the specified direction.This does not actually give focus to that cluster.

        Parameters:
        currentCluster - The starting point of the search.
        direction - Direction to look.
      • addKeyboardNavigationClusters

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

        Adds any keyboard navigation cluster roots that are descendants of {@code view} (including {@code view} if it is a cluster root itself) to {@code views}. Does nothingon API < 26.

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

         static boolean restoreDefaultFocus(@NonNull() View view)

        Gives focus to the default-focus view in the view hierarchy rooted at {@code view}.If the default-focus view cannot be found or if API < 26, this falls back to calling requestFocus.

      • hasExplicitFocusable

         static boolean hasExplicitFocusable(@NonNull() View view)

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

        This method preserves the pre-O behavior of hasFocusable in that only views explicitly set focusable will causethis method to return true. A view set to FOCUSABLE_AUTO that resolvesto focusable will not.

      • generateViewId

         static int generateViewId()

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