public class ViewCompat extends Object
View
introduced after API
level 4 in a backwards compatible fashion.Modifier and Type | Class and Description |
---|---|
static interface |
ViewCompat.FocusDirection |
static interface |
ViewCompat.FocusRealDirection |
static interface |
ViewCompat.FocusRelativeDirection |
static interface |
ViewCompat.ScrollIndicators |
Modifier and Type | Field and Description |
---|---|
static int |
ACCESSIBILITY_LIVE_REGION_ASSERTIVE
Live region mode specifying that accessibility services should interrupt
ongoing speech to immediately announce changes to this view.
|
static int |
ACCESSIBILITY_LIVE_REGION_NONE
Live region mode specifying that accessibility services should not
automatically announce changes to this view.
|
static int |
ACCESSIBILITY_LIVE_REGION_POLITE
Live region mode specifying that accessibility services should announce
changes to this view.
|
static int |
IMPORTANT_FOR_ACCESSIBILITY_AUTO
Automatically determine whether a view is important for accessibility.
|
static int |
IMPORTANT_FOR_ACCESSIBILITY_NO
The view is not important for accessibility.
|
static int |
IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
The view is not important for accessibility, nor are any of its
descendant views.
|
static int |
IMPORTANT_FOR_ACCESSIBILITY_YES
The view is important for accessibility.
|
static int |
LAYER_TYPE_HARDWARE
Indicates that the view has a hardware layer.
|
static int |
LAYER_TYPE_NONE
Indicates that the view does not have a layer.
|
static int |
LAYER_TYPE_SOFTWARE
Indicates that the view has a software layer.
|
static int |
LAYOUT_DIRECTION_INHERIT
Horizontal layout direction of this view is inherited from its parent.
|
static int |
LAYOUT_DIRECTION_LOCALE
Horizontal layout direction of this view is from deduced from the default language
script for the locale.
|
static int |
LAYOUT_DIRECTION_LTR
Horizontal layout direction of this view is from Left to Right.
|
static int |
LAYOUT_DIRECTION_RTL
Horizontal layout direction of this view is from Right to Left.
|
static int |
MEASURED_HEIGHT_STATE_SHIFT
Bit shift of
MEASURED_STATE_MASK to get to the height bits
for functions that combine both width and height into a single int,
such as getMeasuredState(android.view.View) and the childState argument of
resolveSizeAndState(int, int, int) . |
static int |
MEASURED_SIZE_MASK
Bits of
getMeasuredWidthAndState(android.view.View) and
getMeasuredWidthAndState(android.view.View) that provide the actual measured size. |
static int |
MEASURED_STATE_MASK
Bits of
getMeasuredWidthAndState(android.view.View) and
getMeasuredWidthAndState(android.view.View) that provide the additional state bits. |
static int |
MEASURED_STATE_TOO_SMALL
Bit of
getMeasuredWidthAndState(android.view.View) and
getMeasuredWidthAndState(android.view.View) that indicates the measured size
is smaller that the space the view would like to have. |
static int |
OVER_SCROLL_ALWAYS
Deprecated.
Use
View.OVER_SCROLL_ALWAYS directly. This constant will be removed in
a future release. |
static int |
OVER_SCROLL_IF_CONTENT_SCROLLS
Deprecated.
Use
View.OVER_SCROLL_IF_CONTENT_SCROLLS directly. This constant will be
removed in a future release. |
static int |
OVER_SCROLL_NEVER
Deprecated.
Use
View.OVER_SCROLL_NEVER directly. This constant will be removed in
a future release. |
static int |
SCROLL_AXIS_HORIZONTAL
Indicates scrolling along the horizontal axis.
|
static int |
SCROLL_AXIS_NONE
Indicates no axis of view scrolling.
|
static int |
SCROLL_AXIS_VERTICAL
Indicates scrolling along the vertical axis.
|
static int |
SCROLL_INDICATOR_BOTTOM
Scroll indicator direction for the bottom edge of the view.
|
static int |
SCROLL_INDICATOR_END
Scroll indicator direction for the ending edge of the view.
|
static int |
SCROLL_INDICATOR_LEFT
Scroll indicator direction for the left edge of the view.
|
static int |
SCROLL_INDICATOR_RIGHT
Scroll indicator direction for the right edge of the view.
|
static int |
SCROLL_INDICATOR_START
Scroll indicator direction for the starting edge of the view.
|
static int |
SCROLL_INDICATOR_TOP
Scroll indicator direction for the top edge of the view.
|
Modifier | Constructor and Description |
---|---|
protected |
ViewCompat() |
Modifier and Type | Method and Description |
---|---|
static ViewPropertyAnimatorCompat |
animate(View view)
This method returns a ViewPropertyAnimator object, which can be used to animate
specific properties on this View.
|
static boolean |
canScrollHorizontally(View v,
int direction)
Check if this view can be scrolled horizontally in a certain direction.
|
static boolean |
canScrollVertically(View v,
int direction)
Check if this view can be scrolled vertically in a certain direction.
|
static int |
combineMeasuredStates(int curState,
int newState)
Merge two states as returned by
getMeasuredState(View) . |
static WindowInsetsCompat |
dispatchApplyWindowInsets(View view,
WindowInsetsCompat insets)
Request to apply the given window insets to this view or another view in its subtree.
|
static void |
dispatchFinishTemporaryDetach(View view)
Notify a view that its temporary detach has ended; the view is now reattached.
|
static boolean |
dispatchNestedFling(View view,
float velocityX,
float velocityY,
boolean consumed)
Dispatch a fling to a nested scrolling parent.
|
static boolean |
dispatchNestedPreFling(View view,
float velocityX,
float velocityY)
Dispatch a fling to a nested scrolling parent before it is processed by this view.
|
static boolean |
dispatchNestedPreScroll(View view,
int dx,
int dy,
int[] consumed,
int[] offsetInWindow)
Dispatch one step of a nested scroll in progress before this view consumes any portion of it.
|
static boolean |
dispatchNestedScroll(View view,
int dxConsumed,
int dyConsumed,
int dxUnconsumed,
int dyUnconsumed,
int[] offsetInWindow)
Dispatch one step of a nested scroll in progress.
|
static void |
dispatchStartTemporaryDetach(View view)
Notify a view that it is being temporarily detached.
|
static int |
getAccessibilityLiveRegion(View view)
Gets the live region mode for the specified View.
|
static AccessibilityNodeProviderCompat |
getAccessibilityNodeProvider(View view)
Gets the provider for managing a virtual view hierarchy rooted at this View
and reported to
AccessibilityService s
that explore the window content. |
static float |
getAlpha(View view)
The opacity of the view.
|
static ColorStateList |
getBackgroundTintList(View view)
Return the tint applied to the background drawable, if specified.
|
static PorterDuff.Mode |
getBackgroundTintMode(View view)
Return the blending mode used to apply the tint to the background
drawable, if specified.
|
static Rect |
getClipBounds(View view)
Returns a copy of the current
setClipBounds(View, Rect) . |
static Display |
getDisplay(View view)
Gets the logical display to which the view's window has been attached.
|
static float |
getElevation(View view)
The base elevation of this view relative to its parent, in pixels.
|
static boolean |
getFitsSystemWindows(View v)
Returns true if this view should adapt to fit system window insets.
|
static int |
getImportantForAccessibility(View view)
Gets the mode for determining whether this View is important for accessibility
which is if it fires accessibility events and if it is reported to
accessibility services that query the screen.
|
static int |
getLabelFor(View view)
Gets the id of a view for which a given view serves as a label for
accessibility purposes.
|
static int |
getLayerType(View view)
Indicates what type of layer is currently associated with this view.
|
static int |
getLayoutDirection(View view)
Returns the resolved layout direction for this view.
|
static Matrix |
getMatrix(View view)
The transform matrix of this view, which is calculated based on the current
rotation, scale, and pivot properties.
|
static int |
getMeasuredHeightAndState(View view)
Return the full height measurement information for this view as computed
by the most recent call to
View.measure(int, int) . |
static int |
getMeasuredState(View view)
Return only the state bits of
getMeasuredWidthAndState(android.view.View)
and getMeasuredHeightAndState(android.view.View) , combined into one integer. |
static int |
getMeasuredWidthAndState(View view)
Return the full width measurement information for this view as computed
by the most recent call to
View.measure(int, int) . |
static int |
getMinimumHeight(View view)
Returns the minimum height of the view.
|
static int |
getMinimumWidth(View view)
Returns the minimum width of the view.
|
static int |
getOverScrollMode(View v)
Deprecated.
Call
View.getOverScrollMode() directly. This method will be
removed in a future release. |
static int |
getPaddingEnd(View view)
Returns the end padding of the specified view depending on its resolved layout direction.
|
static int |
getPaddingStart(View view)
Returns the start padding of the specified view depending on its resolved layout direction.
|
static ViewParent |
getParentForAccessibility(View view)
Gets the parent for accessibility purposes.
|
static float |
getPivotX(View view)
|
static float |
getPivotY(View view)
|
static float |
getRotation(View view) |
static float |
getRotationX(View view) |
static float |
getRotationY(View view) |
static float |
getScaleX(View view) |
static float |
getScaleY(View view) |
static int |
getScrollIndicators(View view)
Returns a bitmask representing the enabled scroll indicators.
|
static String |
getTransitionName(View view)
Returns the name of the View to be used to identify Views in Transitions.
|
static float |
getTranslationX(View view)
The horizontal location of this view relative to its
left position. |
static float |
getTranslationY(View view)
The vertical location of this view relative to its
top position. |
static float |
getTranslationZ(View view)
The depth location of this view relative to its
elevation . |
static int |
getWindowSystemUiVisibility(View view)
Returns the current system UI visibility that is currently set for the entire window.
|
static float |
getX(View view) |
static float |
getY(View view) |
static float |
getZ(View view)
The visual z position of this view, in pixels.
|
static boolean |
hasAccessibilityDelegate(View v)
Checks whether provided View has an accessibility delegate attached to it.
|
static boolean |
hasNestedScrollingParent(View view)
Returns true if this view has a nested scrolling parent.
|
static boolean |
hasOnClickListeners(View view)
Returns whether the provided view has an attached
View.OnClickListener . |
static boolean |
hasOverlappingRendering(View view)
Returns whether this View has content which overlaps.
|
static boolean |
hasTransientState(View view)
Indicates whether the view is currently tracking transient state that the
app should not need to concern itself with saving and restoring, but that
the framework should take special note to preserve when possible.
|
static boolean |
isAttachedToWindow(View view)
Returns true if the provided view is currently attached to a window.
|
static boolean |
isImportantForAccessibility(View view)
Computes whether this view should be exposed for accessibility.
|
static boolean |
isInLayout(View view)
Returns whether the view hierarchy is currently undergoing a layout pass.
|
static boolean |
isLaidOut(View view)
Returns true if
view has been through at least one layout since it
was last attached to or detached from a window. |
static boolean |
isLayoutDirectionResolved(View view)
Returns whether layout direction has been resolved.
|
static boolean |
isNestedScrollingEnabled(View view)
Returns true if nested scrolling is enabled for this view.
|
static boolean |
isOpaque(View view)
Deprecated.
Use
View.isOpaque() directly. This method will be
removed in a future release. |
static boolean |
isPaddingRelative(View view)
Return if the padding as been set through relative values
View.setPaddingRelative(int, int, int, int) or thru |
static void |
jumpDrawablesToCurrentState(View v)
On API 11 devices and above, call
Drawable.jumpToCurrentState()
on all Drawable objects associated with this view. |
static void |
offsetLeftAndRight(View view,
int offset)
Offset this view's horizontal location by the specified amount of pixels.
|
static void |
offsetTopAndBottom(View view,
int offset)
Offset this view's vertical location by the specified number of pixels.
|
static WindowInsetsCompat |
onApplyWindowInsets(View view,
WindowInsetsCompat insets)
Called when the view should apply
WindowInsetsCompat according to its internal policy. |
static void |
onInitializeAccessibilityEvent(View v,
AccessibilityEvent event)
Initializes an
AccessibilityEvent with information about
this View which is the event source. |
static void |
onInitializeAccessibilityNodeInfo(View v,
AccessibilityNodeInfoCompat info)
Initializes an
AccessibilityNodeInfoCompat with information
about this view. |
static void |
onPopulateAccessibilityEvent(View v,
AccessibilityEvent event)
Called from
View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)
giving a chance to this View to populate the accessibility event with its
text content. |
static boolean |
performAccessibilityAction(View view,
int action,
Bundle arguments)
Performs the specified accessibility action on the view.
|
static void |
postInvalidateOnAnimation(View view)
Cause an invalidate to happen on the next animation time step, typically the
next display frame.
|
static void |
postInvalidateOnAnimation(View view,
int left,
int top,
int right,
int bottom)
Cause an invalidate of the specified area to happen on the next animation
time step, typically the next display frame.
|
static void |
postOnAnimation(View view,
Runnable action)
Causes the Runnable to execute on the next animation time step.
|
static void |
postOnAnimationDelayed(View view,
Runnable action,
long delayMillis)
Causes the Runnable to execute on the next animation time step,
after the specified amount of time elapses.
|
static void |
requestApplyInsets(View view)
Ask that a new dispatch of
View.onApplyWindowInsets(WindowInsets) be performed. |
static int |
resolveSizeAndState(int size,
int measureSpec,
int childMeasuredState)
Utility to reconcile a desired size and state, with constraints imposed
by a MeasureSpec.
|
static void |
setAccessibilityDelegate(View v,
AccessibilityDelegateCompat delegate)
Sets a delegate for implementing accessibility support via composition
(as opposed to inheritance).
|
static void |
setAccessibilityLiveRegion(View view,
int mode)
Sets the live region mode for the specified view.
|
static void |
setActivated(View view,
boolean activated)
Changes the activated state of this view.
|
static void |
setAlpha(View view,
float value)
Sets the opacity of the view.
|
static void |
setBackground(View view,
Drawable background)
Set the background of the
view to a given Drawable, or remove the background. |
static void |
setBackgroundTintList(View view,
ColorStateList tintList)
Applies a tint to the background drawable.
|
static void |
setBackgroundTintMode(View view,
PorterDuff.Mode mode)
Specifies the blending mode used to apply the tint specified by
setBackgroundTintList(android.view.View, android.content.res.ColorStateList) to
the background drawable. |
static void |
setChildrenDrawingOrderEnabled(ViewGroup viewGroup,
boolean enabled)
Tells the ViewGroup whether to draw its children in the order defined by the method
ViewGroup.getChildDrawingOrder(int, int) . |
static void |
setClipBounds(View view,
Rect clipBounds)
Sets a rectangular area on this view to which the view will be clipped
when it is drawn.
|
static void |
setElevation(View view,
float elevation)
Sets the base elevation of this view, in pixels.
|
static void |
setFitsSystemWindows(View view,
boolean fitSystemWindows)
Sets whether or not this view should account for system screen decorations
such as the status bar and inset its content; that is, controlling whether
the default implementation of
View.fitSystemWindows(Rect) will be
executed. |
static void |
setHasTransientState(View view,
boolean hasTransientState)
Set whether this view is currently tracking transient state that the
framework should attempt to preserve when possible.
|
static void |
setImportantForAccessibility(View view,
int mode)
Sets how to determine whether this view is important for accessibility
which is if it fires accessibility events and if it is reported to
accessibility services that query the screen.
|
static void |
setLabelFor(View view,
int labeledId)
Sets the id of a view for which a given view serves as a label for
accessibility purposes.
|
static void |
setLayerPaint(View view,
Paint paint)
Updates the
Paint object used with the current layer (used only if the current
layer type is not set to LAYER_TYPE_NONE ). |
static void |
setLayerType(View view,
int layerType,
Paint paint)
Specifies the type of layer backing this view.
|
static void |
setLayoutDirection(View view,
int layoutDirection)
Set the layout direction for this view.
|
static void |
setNestedScrollingEnabled(View view,
boolean enabled)
Enable or disable nested scrolling for this view.
|
static void |
setOnApplyWindowInsetsListener(View v,
OnApplyWindowInsetsListener listener)
Set an
OnApplyWindowInsetsListener to take over the policy for applying
window insets to this view. |
static void |
setOverScrollMode(View v,
int overScrollMode)
Deprecated.
Call
View.setOverScrollMode(int) directly. This method will be
removed in a future release. |
static void |
setPaddingRelative(View view,
int start,
int top,
int end,
int bottom)
Sets the relative padding.
|
static void |
setPivotX(View view,
float value)
|
static void |
setPivotY(View view,
float value)
|
static void |
setPointerIcon(View view,
PointerIconCompat pointerIcon)
Set the pointer icon for the current view.
|
static void |
setRotation(View view,
float value)
Sets the degrees that the view is rotated around the pivot point.
|
static void |
setRotationX(View view,
float value)
Sets the degrees that the view is rotated around the horizontal axis through the pivot point.
|
static void |
setRotationY(View view,
float value)
Sets the degrees that the view is rotated around the vertical axis through the pivot point.
|
static void |
setSaveFromParentEnabled(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.
|
static void |
setScaleX(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.
|
static void |
setScaleY(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.
|
static void |
setScrollIndicators(View view,
int indicators)
Sets the state of all scroll indicators.
|
static void |
setScrollIndicators(View view,
int indicators,
int mask)
Sets the state of the scroll indicators specified by the mask.
|
static void |
setTransitionName(View view,
String transitionName)
Sets the name of the View to be used to identify Views in Transitions.
|
static void |
setTranslationX(View view,
float value)
Sets the horizontal location of this view relative to its left position.
|
static void |
setTranslationY(View view,
float value)
Sets the vertical location of this view relative to its top position.
|
static void |
setTranslationZ(View view,
float translationZ)
Sets the depth location of this view relative to its
elevation . |
static void |
setX(View view,
float value)
Sets the visual x position of this view, in pixels.
|
static void |
setY(View view,
float value)
Sets the visual y position of this view, in pixels.
|
static void |
setZ(View view,
float z)
Sets the visual z position of this view, in pixels.
|
static boolean |
startNestedScroll(View view,
int axes)
Begin a nestable scroll operation along the given axes.
|
static void |
stopNestedScroll(View view)
Stop a nested scroll in progress.
|
@Deprecated public static final int OVER_SCROLL_ALWAYS
View.OVER_SCROLL_ALWAYS
directly. This constant will be removed in
a future release.@Deprecated public static final int OVER_SCROLL_IF_CONTENT_SCROLLS
View.OVER_SCROLL_IF_CONTENT_SCROLLS
directly. This constant will be
removed in a future release.@Deprecated public static final int OVER_SCROLL_NEVER
View.OVER_SCROLL_NEVER
directly. This constant will be removed in
a future release.public static final int IMPORTANT_FOR_ACCESSIBILITY_AUTO
public static final int IMPORTANT_FOR_ACCESSIBILITY_YES
public static final int IMPORTANT_FOR_ACCESSIBILITY_NO
public static final int IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
public static final int ACCESSIBILITY_LIVE_REGION_NONE
Use with setAccessibilityLiveRegion(View, int)
.
public static final int ACCESSIBILITY_LIVE_REGION_POLITE
Use with setAccessibilityLiveRegion(View, int)
.
public static final int ACCESSIBILITY_LIVE_REGION_ASSERTIVE
Use with setAccessibilityLiveRegion(View, int)
.
public static final int LAYER_TYPE_NONE
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 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
public static final int LAYOUT_DIRECTION_RTL
public static final int LAYOUT_DIRECTION_INHERIT
setLayoutDirection(android.view.View, int)
.public static final int LAYOUT_DIRECTION_LOCALE
setLayoutDirection(android.view.View, int)
.public static final int MEASURED_SIZE_MASK
getMeasuredWidthAndState(android.view.View)
and
getMeasuredWidthAndState(android.view.View)
that provide the actual measured size.public static final int MEASURED_STATE_MASK
getMeasuredWidthAndState(android.view.View)
and
getMeasuredWidthAndState(android.view.View)
that provide the additional state bits.public static final int MEASURED_HEIGHT_STATE_SHIFT
MEASURED_STATE_MASK
to get to the height bits
for functions that combine both width and height into a single int,
such as getMeasuredState(android.view.View)
and the childState argument of
resolveSizeAndState(int, int, int)
.public static final int MEASURED_STATE_TOO_SMALL
getMeasuredWidthAndState(android.view.View)
and
getMeasuredWidthAndState(android.view.View)
that indicates the measured size
is smaller that the space the view would like to have.public static final int SCROLL_AXIS_NONE
public static final int SCROLL_AXIS_HORIZONTAL
public static final int SCROLL_AXIS_VERTICAL
public static final int SCROLL_INDICATOR_TOP
public static final int SCROLL_INDICATOR_BOTTOM
public static final int SCROLL_INDICATOR_LEFT
public static final int SCROLL_INDICATOR_RIGHT
public static final int SCROLL_INDICATOR_START
public static final int SCROLL_INDICATOR_END
public static boolean canScrollHorizontally(View v, int direction)
v
- The View against which to invoke the method.direction
- Negative to check scrolling left, positive to check scrolling right.public static boolean canScrollVertically(View v, int direction)
v
- The View against which to invoke the method.direction
- Negative to check scrolling up, positive to check scrolling down.@Deprecated public static int getOverScrollMode(View v)
View.getOverScrollMode()
directly. This method will be
removed in a future release.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
.v
- The View against which to invoke the method.@Deprecated public static void setOverScrollMode(View v, int overScrollMode)
View.setOverScrollMode(int)
directly. This method will be
removed in a future release.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 the
view is capable of scrolling.v
- The View against which to invoke the method.overScrollMode
- The new over-scroll mode for this view.public static void onPopulateAccessibilityEvent(View v, AccessibilityEvent event)
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
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 AccessibilityDelegateCompat
has been specified via calling
setAccessibilityDelegate(View, AccessibilityDelegateCompat)
its
AccessibilityDelegateCompat.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.
v
- The View against which to invoke the method.event
- The accessibility event which to populate.View.sendAccessibilityEvent(int)
,
View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)
public static void onInitializeAccessibilityEvent(View v, AccessibilityEvent event)
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 AccessibilityDelegateCompat
has been specified via calling
setAccessibilityDelegate(View, AccessibilityDelegateCompat)
, its
AccessibilityDelegateCompat.onInitializeAccessibilityEvent(View, AccessibilityEvent)
is responsible for handling this call.
v
- The View against which to invoke the method.event
- The event to initialize.View.sendAccessibilityEvent(int)
,
View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)
public static void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info)
AccessibilityNodeInfoCompat
with information
about this view. The base implementation sets:
AccessibilityNodeInfoCompat.setParent(View)
,AccessibilityNodeInfoCompat.setBoundsInParent(Rect)
,AccessibilityNodeInfoCompat.setBoundsInScreen(Rect)
,AccessibilityNodeInfoCompat.setPackageName(CharSequence)
,AccessibilityNodeInfoCompat.setClassName(CharSequence)
,AccessibilityNodeInfoCompat.setContentDescription(CharSequence)
,AccessibilityNodeInfoCompat.setEnabled(boolean)
,AccessibilityNodeInfoCompat.setClickable(boolean)
,AccessibilityNodeInfoCompat.setFocusable(boolean)
,AccessibilityNodeInfoCompat.setFocused(boolean)
,AccessibilityNodeInfoCompat.setLongClickable(boolean)
,AccessibilityNodeInfoCompat.setSelected(boolean)
,
If an AccessibilityDelegateCompat
has been specified via calling
setAccessibilityDelegate(View, AccessibilityDelegateCompat)
, its
AccessibilityDelegateCompat.onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfoCompat)
method is responsible for handling this call.
v
- The View against which to invoke the method.info
- The instance to initialize.public static void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate)
AccessibilityDelegateCompat
.
On platform versions prior to API 14, this method is a no-op.
Note: On platform versions prior to
API 23
, delegate methods on
views in the android.widget.*
package are called before
host methods. This prevents certain properties such as class name from
being modified by overriding
AccessibilityDelegateCompat.onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfoCompat)
,
as any changes will be overwritten by the host class.
Starting in API 23
, delegate
methods are called after host methods, which all properties to be
modified without being overwritten by the host class.
delegate
- the object to which accessibility method calls should be
delegatedAccessibilityDelegateCompat
public static boolean hasAccessibilityDelegate(View v)
v
- The View instance to checkpublic static boolean hasTransientState(View view)
view
- View to check for transient statepublic static void setHasTransientState(View view, boolean hasTransientState)
view
- View tracking transient statehasTransientState
- true if this view has transient statepublic static void postInvalidateOnAnimation(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.
view
- View to invalidatepublic static void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom)
Cause an invalidate of the specified area to happen on the next animation time step, typically the next display frame.
This method can be invoked from outside of the UI thread only when this View is attached to a window.
view
- View to invalidateleft
- 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.public static void postOnAnimation(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 thread only when this View is attached to a window.
view
- View to post this Runnable toaction
- The Runnable that will be executed.public static void postOnAnimationDelayed(View view, Runnable action, long delayMillis)
Causes the Runnable to execute on the next animation time step, after the specified amount of time elapses. 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.
view
- The view to post this Runnable toaction
- The Runnable that will be executed.delayMillis
- The delay (in milliseconds) until the Runnable
will be executed.public static int getImportantForAccessibility(View view)
view
- The view whose property to get.IMPORTANT_FOR_ACCESSIBILITY_YES
,
IMPORTANT_FOR_ACCESSIBILITY_NO
,
IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
,
IMPORTANT_FOR_ACCESSIBILITY_AUTO
public static void setImportantForAccessibility(View view, int mode)
Note: If the current platform version does not support the
IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
mode, then
IMPORTANT_FOR_ACCESSIBILITY_NO
will be used as it is the
closest terms of semantics.
view
- The view whose property to set.mode
- How to determine whether this view is important for accessibility.IMPORTANT_FOR_ACCESSIBILITY_YES
,
IMPORTANT_FOR_ACCESSIBILITY_NO
,
IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
,
IMPORTANT_FOR_ACCESSIBILITY_AUTO
public static boolean isImportantForAccessibility(View view)
If an ancestor of this view has importance
IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
, this method
returns false
.
Otherwise, the value is computed according to the view's
getImportantForAccessibility(View)
value:
IMPORTANT_FOR_ACCESSIBILITY_NO
or
IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
, return false
IMPORTANT_FOR_ACCESSIBILITY_YES
, return true
IMPORTANT_FOR_ACCESSIBILITY_AUTO
, return true
if
view satisfies any of the following:
View.isClickable()
,
View.isLongClickable()
, or View.isFocusable()
AccessibilityDelegateCompat
View.OnTouchListener
,
View.OnKeyListener
, etc.
getAccessibilityLiveRegion(View)
is not
ACCESSIBILITY_LIVE_REGION_NONE
.
Note: Prior to API 21, this method will always return true
.
setImportantForAccessibility(View, int)
,
getImportantForAccessibility(View)
public static boolean performAccessibilityAction(View view, int action, Bundle arguments)
AccessibilityNodeInfoCompat
.
If an AccessibilityDelegateCompat
has been specified via calling
setAccessibilityDelegate(View, AccessibilityDelegateCompat)
its
AccessibilityDelegateCompat.performAccessibilityAction(View, int, Bundle)
is responsible for handling this call.
action
- The action to perform.arguments
- Optional action arguments.public static AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view)
AccessibilityService
s
that explore the window content.
If this method returns an instance, this instance is responsible for managing
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 AccessibilityDelegateCompat
has been specified via calling
setAccessibilityDelegate(View, AccessibilityDelegateCompat)
its
AccessibilityDelegateCompat.getAccessibilityNodeProvider(View)
is responsible for handling this call.
view
- The view whose property to get.AccessibilityNodeProviderCompat
public static float getAlpha(View view)
By default this is 1.0f. Prior to API 11, the returned value is always 1.0f.
public 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 following
properties of the paint are taken into account when composing the layer:
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 disabled
,
software
and hardware
for more information on when and how to use layers.
view
- View to set the layer type forlayerType
- The type of layer to use with this view, must be one of
LAYER_TYPE_NONE
, LAYER_TYPE_SOFTWARE
or
LAYER_TYPE_HARDWARE
paint
- The paint used to compose the layer. This argument is optional
and can be null. It is ignored when the layer type is
LAYER_TYPE_NONE
public static int getLayerType(View view)
LAYER_TYPE_NONE
.
Refer to the documentation of
setLayerType(android.view.View, int, android.graphics.Paint)
for more information on the different types of layers.view
- The view to fetch the layer type fromLAYER_TYPE_NONE
, LAYER_TYPE_SOFTWARE
or
LAYER_TYPE_HARDWARE
setLayerType(android.view.View, int, android.graphics.Paint)
,
LAYER_TYPE_NONE
,
LAYER_TYPE_SOFTWARE
,
LAYER_TYPE_HARDWARE
public static int getLabelFor(View view)
view
- The view on which to invoke the corresponding method.public static void setLabelFor(View view, @IdRes int labeledId)
view
- The view on which to invoke the corresponding method.labeledId
- The labeled view id.public static void setLayerPaint(View view, Paint paint)
Paint
object used with the current layer (used only if the current
layer type is not set to LAYER_TYPE_NONE
). Changed properties of the Paint
provided to setLayerType(android.view.View, int, android.graphics.Paint)
will be used the next time the View is redrawn, but
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 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:
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.
view
- View to set a layer paint forpaint
- The paint used to compose the layer. This argument is optional
and can be null. It is ignored when the layer type is
LAYER_TYPE_NONE
setLayerType(View, int, android.graphics.Paint)
public static int getLayoutDirection(View view)
view
- View to get layout direction forLAYOUT_DIRECTION_RTL
if the layout direction is RTL or returns
LAYOUT_DIRECTION_LTR
if the layout direction is not RTL.
For compatibility, this will return LAYOUT_DIRECTION_LTR
if API version
is lower than Jellybean MR1 (API 17)public static void setLayoutDirection(View view, int layoutDirection)
view
- View to set layout direction forlayoutDirection
- the layout direction to set. Should be one of:
LAYOUT_DIRECTION_LTR
,
LAYOUT_DIRECTION_RTL
,
LAYOUT_DIRECTION_INHERIT
,
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 LAYOUT_DIRECTION_LTR
.public static ViewParent getParentForAccessibility(View view)
view
- View to retrieve parent for@Deprecated public static boolean isOpaque(View view)
View.isOpaque()
directly. This method will be
removed in a future release.public static int resolveSizeAndState(int size, int measureSpec, int childMeasuredState)
MEASURED_SIZE_MASK
bits and
optionally the bit MEASURED_STATE_TOO_SMALL
set if the resulting
size is smaller than the size the view wants to be.size
- How big the view wants to bemeasureSpec
- Constraints imposed by the parentMEASURED_SIZE_MASK
and MEASURED_STATE_TOO_SMALL
.public static int getMeasuredWidthAndState(View view)
View.measure(int, int)
.
This result is a bit mask as defined by MEASURED_SIZE_MASK
and
MEASURED_STATE_TOO_SMALL
.
This should be used during measurement and layout calculations only. Use
View.getWidth()
to see how wide a view is after layout.public static int getMeasuredHeightAndState(View view)
View.measure(int, int)
.
This result is a bit mask as defined by MEASURED_SIZE_MASK
and
MEASURED_STATE_TOO_SMALL
.
This should be used during measurement and layout calculations only. Use
View.getHeight()
to see how wide a view is after layout.public static int getMeasuredState(View view)
getMeasuredWidthAndState(android.view.View)
and getMeasuredHeightAndState(android.view.View)
, combined into one integer.
The width component is in the regular bits MEASURED_STATE_MASK
and the height component is at the shifted bits
MEASURED_HEIGHT_STATE_SHIFT
>>MEASURED_STATE_MASK
.public static int combineMeasuredStates(int curState, int newState)
getMeasuredState(View)
.curState
- The current state as returned from a view or the result
of combining multiple views.newState
- The new view state to combine.public static int getAccessibilityLiveRegion(View view)
view
- The view from which to obtain the live region modesetAccessibilityLiveRegion(View, int)
public static void setAccessibilityLiveRegion(View view, int mode)
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 ACCESSIBILITY_LIVE_REGION_POLITE
.
To disable change notifications for this view, use
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
ACCESSIBILITY_LIVE_REGION_POLITE
.
If the view's changes should interrupt ongoing speech and notify the user
immediately, use ACCESSIBILITY_LIVE_REGION_ASSERTIVE
.
view
- The view on which to set the live region modemode
- The live region mode for this view, one of:
public static int getPaddingStart(View view)
view
- The view to get padding forpublic static int getPaddingEnd(View view)
view
- The view to get padding forpublic static void setPaddingRelative(View view, int start, int top, int end, int bottom)
getPaddingStart(android.view.View)
, View.getPaddingTop()
,
getPaddingEnd(android.view.View)
and View.getPaddingBottom()
may be different
from the values set in this call.view
- The view on which to set relative paddingstart
- the start padding in pixelstop
- the top padding in pixelsend
- the end padding in pixelsbottom
- the bottom padding in pixelspublic static void dispatchStartTemporaryDetach(View view)
public static void dispatchFinishTemporaryDetach(View view)
public static float getTranslationX(View view)
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.
public static float getTranslationY(View view)
top
position.
This position is post-layout, in addition to wherever the object's
layout placed it.
Prior to API 11 this will return 0.
@Nullable public static Matrix getMatrix(View view)
Prior to 11, this method will return null
.
view
- The view whose Matrix will be returnedgetRotation(View)
,
getScaleX(View)
,
getScaleY(View)
,
getPivotX(View)
,
getPivotY(View)
public static int getMinimumWidth(View view)
Prior to API 16 this will return 0.
public static int getMinimumHeight(View view)
Prior to API 16 this will return 0.
public static ViewPropertyAnimatorCompat animate(View view)
Prior to API 14, this method will do nothing.
public static void setTranslationX(View view, float value)
Prior to API 11 this will have no effect.
value
- The horizontal position of this view relative to its left position,
in pixels.public static void setTranslationY(View view, float value)
Prior to API 11 this will have no effect.
value
- The vertical position of this view relative to its top position,
in pixels.public static void setAlpha(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.
value
- The opacity of the view.public static void setX(View view, float value)
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.
value
- The visual x position of this view, in pixels.public static void setY(View view, float value)
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.
value
- The visual y position of this view, in pixels.public static void setRotation(View view, float value)
Prior to API 11 this will have no effect.
value
- The degrees of rotation.public static void setRotationX(View view, float value)
Prior to API 11 this will have no effect.
value
- The degrees of X rotation.public static void setRotationY(View view, float value)
Prior to API 11 this will have no effect.
value
- The degrees of Y rotation.public static void setScaleX(View view, float value)
Prior to API 11 this will have no effect.
value
- The scaling factor.public static void setScaleY(View view, float value)
Prior to API 11 this will have no effect.
value
- The scaling factor.public static float getPivotX(View view)
public static void setPivotX(View view, float value)
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 the
explicitly set pivotX and pivotY values.
Prior to API 11 this will have no effect.
value
- The x location of the pivot point.public static float getPivotY(View view)
rotated
and scaled
.
Prior to API 11 this will return 0.
public static void setPivotY(View view, float value)
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 the
explicitly set pivotX and pivotY values.
Prior to API 11 this will have no effect.
value
- The y location of the pivot point.public static float getRotation(View view)
public static float getRotationX(View view)
public static float getRotationY(View view)
public static float getScaleX(View view)
public static float getScaleY(View view)
public static float getX(View view)
public static float getY(View view)
public static void setElevation(View view, float elevation)
public static float getElevation(View view)
public static void setTranslationZ(View view, float translationZ)
elevation
.public static float getTranslationZ(View view)
elevation
.public static void setTransitionName(View view, String transitionName)
view
- The View against which to invoke the method.transitionName
- The name of the View to uniquely identify it for Transitions.public static String getTransitionName(View view)
This returns null if the View has not been given a name.
view
- The View against which to invoke the method.public static int getWindowSystemUiVisibility(View view)
public static void requestApplyInsets(View view)
View.onApplyWindowInsets(WindowInsets)
be performed. This
falls back to View.requestFitSystemWindows()
where available.public static void setChildrenDrawingOrderEnabled(ViewGroup viewGroup, boolean enabled)
ViewGroup.getChildDrawingOrder(int, int)
.enabled
- true if the order of the children when drawing is determined by
ViewGroup.getChildDrawingOrder(int, int)
, false otherwise
Prior to API 7 this will have no effect.
public static boolean getFitsSystemWindows(View v)
public static void setFitsSystemWindows(View view, boolean fitSystemWindows)
View.fitSystemWindows(Rect)
will be
executed. See that method for more details.public static void jumpDrawablesToCurrentState(View v)
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.
public static void setOnApplyWindowInsetsListener(View v, OnApplyWindowInsetsListener listener)
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.public static WindowInsetsCompat onApplyWindowInsets(View view, WindowInsetsCompat insets)
WindowInsetsCompat
according to its internal policy.
Clients may supply an OnApplyWindowInsetsListener
to a view. If one is set
it will be called during dispatch instead of this method. The listener may optionally
call this method from its own implementation if it wishes to apply the view's default
insets policy in addition to its own.
view
- The View against which to invoke the method.insets
- Insets to applypublic static WindowInsetsCompat dispatchApplyWindowInsets(View view, WindowInsetsCompat insets)
This method should be called by clients wishing to apply insets corresponding to areas obscured by window decorations or overlays. This can include the status and navigation bars, action bars, input methods and more. New inset categories may be added in the future. The method returns the insets provided minus any that were applied by this view or its children.
insets
- Insets to applypublic static void setSaveFromParentEnabled(View v, boolean enabled)
enabled
- Set to false to disable state saving, or true
(the default) to allow it.public static void setActivated(View view, boolean activated)
activated
- true if the view must be activated, false otherwisepublic static boolean hasOverlappingRendering(View view)
This function, intended to be overridden by specific View types, is an optimization when alpha is set on a view. If rendering overlaps in a view with alpha < 1, that view is drawn to an offscreen buffer and then composited into place, which can be expensive. If the view has no overlapping rendering, the view can draw each primitive with the appropriate alpha value directly. An example of overlapping rendering is a TextView with a background image, such as a Button. An example of non-overlapping rendering is a TextView with no background, or an ImageView with only the foreground image. The default implementation returns true; subclasses should override if they have cases which can be optimized.
public static boolean isPaddingRelative(View view)
View.setPaddingRelative(int, int, int, int)
or thrupublic static void setBackground(View view, Drawable background)
view
to a given Drawable, or remove the background. If the
background has padding, 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 is
desired, please usesetPadding(int, int, int, int)
.public static ColorStateList getBackgroundTintList(View view)
Only returns meaningful info when running on API v21 or newer, or if view
implements the TintableBackgroundView
interface.
public static void setBackgroundTintList(View view, ColorStateList tintList)
This will always take effect when running on API v21 or newer. When running on platforms
previous to API v21, it will only take effect if view
implement the
TintableBackgroundView
interface.
public static PorterDuff.Mode getBackgroundTintMode(View view)
Only returns meaningful info when running on API v21 or newer, or if view
implements the TintableBackgroundView
interface.
public static void setBackgroundTintMode(View view, PorterDuff.Mode mode)
setBackgroundTintList(android.view.View, android.content.res.ColorStateList)
to
the background drawable. The default mode is PorterDuff.Mode#SRC_IN
.
This will always take effect when running on API v21 or newer. When running on platforms
previous to API v21, it will only take effect if view
implement the
TintableBackgroundView
interface.
public static void setNestedScrollingEnabled(View view, boolean enabled)
If this property is set to true the view will be permitted to initiate nested
scrolling operations with a compatible parent view in the current hierarchy. If this
view does not implement nested scrolling this will have no effect. Disabling nested scrolling
while a nested scroll is in progress has the effect of
stopping
the nested scroll.
enabled
- true to enable nested scrolling, false to disableisNestedScrollingEnabled(View)
public static boolean isNestedScrollingEnabled(View 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 data about the scroll operation in progress to a compatible and cooperating nested scrolling parent.
setNestedScrollingEnabled(View, boolean)
public static boolean startNestedScroll(View view, int 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 case
of a touch scroll this corresponds to the initial MotionEvent.ACTION_DOWN
.
In the case of touch scrolling the nested scroll will be terminated automatically in
the same manner as ViewParent.requestDisallowInterceptTouchEvent(boolean)
.
In the event of programmatic scrolling the caller must explicitly call
stopNestedScroll(View)
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 scrolling
parent at least partially consumed the scroll and the caller should adjust the amount it
scrolls by.
After applying the remainder of the scroll delta the caller should invoke
dispatchNestedScroll
, passing
both the delta consumed and the delta unconsumed. A nested scrolling parent may treat
these values differently. See
NestedScrollingParent.onNestedScroll(View, int, int, int, int)
.
axes
- Flags consisting of a combination of SCROLL_AXIS_HORIZONTAL
and/or SCROLL_AXIS_VERTICAL
.stopNestedScroll(View)
,
dispatchNestedPreScroll(View, int, int, int[], int[])
,
dispatchNestedScroll(View, int, int, int, int, int[])
public static void stopNestedScroll(View view)
Calling this method when a nested scroll is not currently in progress is harmless.
startNestedScroll(View, int)
public static boolean hasNestedScrollingParent(View view)
The presence of a nested scrolling parent indicates that this view has initiated a nested scroll and it was accepted by an ancestor view further up the view hierarchy.
public static boolean dispatchNestedScroll(View view, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow)
Implementations of views that support nested scrolling should call this to report
info about a scroll in progress to the current nested scrolling parent. If a nested scroll
is not currently in progress or nested scrolling is not
enabled
for this view this method does nothing.
Compatible View implementations should also call
dispatchNestedPreScroll
before
consuming a component of the scroll event themselves.
dxConsumed
- Horizontal distance in pixels consumed by this view during this scroll stepdyConsumed
- Vertical distance in pixels consumed by this view during this scroll stepdxUnconsumed
- Horizontal scroll distance in pixels not consumed by this viewdyUnconsumed
- Horizontal scroll distance in pixels not consumed by this viewoffsetInWindow
- Optional. If not null, on return this will contain the offset
in local view coordinates of this view from before this operation
to after it completes. View implementations may use this to adjust
expected input coordinate tracking.dispatchNestedPreScroll(View, int, int, int[], int[])
public static boolean dispatchNestedPreScroll(View view, int dx, int dy, int[] consumed, int[] offsetInWindow)
Nested pre-scroll events are to nested scroll events what touch intercept is to touch.
dispatchNestedPreScroll
offers an opportunity for the parent view in a nested
scrolling operation to consume some or all of the scroll operation before the child view
consumes it.
dx
- Horizontal scroll distance in pixelsdy
- Vertical scroll distance in pixelsconsumed
- Output. If not null, consumed[0] will contain the consumed component of dx
and consumed[1] the consumed dy.offsetInWindow
- Optional. If not null, on return this will contain the offset
in local view coordinates of this view from before this operation
to after it completes. View implementations may use this to adjust
expected input coordinate tracking.dispatchNestedScroll(View, int, int, int, int, int[])
public static boolean dispatchNestedFling(View view, float velocityX, float velocityY, boolean consumed)
This method should be used to indicate that a nested scrolling child has detected
suitable conditions for a fling. Generally this means that a touch scroll has ended with a
velocity
in the direction of scrolling that meets or exceeds
the minimum fling velocity
along a scrollable axis.
If a nested scrolling child view would normally fling but it is at the edge of its own content, it can use this method to delegate the fling to its nested scrolling parent instead. The parent may optionally consume the fling or observe a child fling.
velocityX
- Horizontal fling velocity in pixels per secondvelocityY
- Vertical fling velocity in pixels per secondconsumed
- true if the child consumed the fling, false otherwisepublic static boolean dispatchNestedPreFling(View view, float velocityX, float velocityY)
Nested pre-fling events are to nested fling events what touch intercept is to touch
and what nested pre-scroll is to nested scroll. dispatchNestedPreFling
offsets an opportunity for the parent view in a nested fling to fully consume the fling
before the child view consumes it. If this method returns true
, a nested
parent view consumed the fling and this view should not scroll as a result.
For a better user experience, only one view in a nested scrolling chain should consume the fling at a time. If a parent view consumed the fling this method will return false. Custom view implementations should account for this in two ways:
dispatchNestedPreFling
; consume the fling and settle to a valid
position regardless.Views should also not offer fling velocities to nested parent views along an axis
where scrolling is not currently supported; a ScrollView
should not offer a horizontal fling velocity to its parents since scrolling along that
axis is not permitted and carrying velocity along that motion does not make sense.
velocityX
- Horizontal fling velocity in pixels per secondvelocityY
- Vertical fling velocity in pixels per secondpublic static boolean isInLayout(View view)
View.requestLayout()
during a layout pass.
Compatibility:
false
public static boolean isLaidOut(View view)
view
has been through at least one layout since it
was last attached to or detached from a window.public static boolean isLayoutDirectionResolved(View view)
Compatibility:
false
public static float getZ(View view)
translationZ
property plus the current
elevation
property.public static void setZ(View view, float z)
translationZ
property to be the difference between
the x value passed in and the current elevation
property.
Compatibility:
z
- The visual z position of this view, in pixels.public static void offsetTopAndBottom(View view, int offset)
offset
- the number of pixels to offset the view bypublic static void offsetLeftAndRight(View view, int offset)
offset
- the number of pixels to offset the view bypublic static void setClipBounds(View view, Rect clipBounds)
Prior to API 18 this does nothing.
view
- The view to set clipBounds.clipBounds
- The rectangular area, in the local coordinates of
this view, to which future drawing operations will be clipped.public static Rect getClipBounds(View view)
setClipBounds(View, Rect)
.
Prior to API 18 this will return null.
public static boolean isAttachedToWindow(View view)
public static boolean hasOnClickListeners(View view)
View.OnClickListener
.public static void setScrollIndicators(@NonNull View view, int indicators)
See setScrollIndicators(View, int, int)
for usage information.
indicators
- a bitmask of indicators that should be enabled, or
0
to disable all indicatorssetScrollIndicators(View, int, int)
,
getScrollIndicators(View)
public static void setScrollIndicators(@NonNull View view, int indicators, int mask)
setScrollIndicators(View, int)
.
When a scroll indicator is enabled, it will be displayed if the view can scroll in the direction of the indicator.
Multiple indicator types may be enabled or disabled by passing the logical OR of the desired types. If multiple types are specified, they will all be set to the same enabled state.
For example, to enable the top scroll indicatorExample: setScrollIndicators
indicators
- the indicator direction, or the logical OR of multiple
indicator directions. One or more of:
setScrollIndicators(View, int)
,
getScrollIndicators(View)
public static int getScrollIndicators(@NonNull View view)
For example, if the top and left scroll indicators are enabled and all
other indicators are disabled, the return value will be
ViewCompat.SCROLL_INDICATOR_TOP | ViewCompat.SCROLL_INDICATOR_LEFT
.
To check whether the bottom scroll indicator is enabled, use the value
of (ViewCompat.getScrollIndicators(view) & ViewCompat.SCROLL_INDICATOR_BOTTOM) != 0
.
public static void setPointerIcon(@NonNull View view, PointerIconCompat pointerIcon)
pointerIcon
- A PointerIconCompat instance which will be shown when the mouse hovers.public static Display getDisplay(@NonNull View view)
Compatibility: