Unit |
addChildrenForAccessibility(outChildren: ArrayList<View!>!)
Adds the children of this View relevant for accessibility to the given list as output. Since some Views are not important for accessibility the added child views are not necessarily direct children of this view, rather they are the first level of descendants important for accessibility.
|
Unit |
addExtraDataToAccessibilityNodeInfo(info: AccessibilityNodeInfo, extraDataKey: String, arguments: Bundle?)
Adds extra data to an AccessibilityNodeInfo based on an explicit request for the additional data.
This method only needs overloading if the node is marked as having extra data available.
|
Unit |
addFocusables(views: ArrayList<View!>!, direction: Int)
Add any focusable views that are descendants of this view (possibly including this view if it is focusable itself) to views. If we are in touch mode, only add views that are also focusable in touch mode.
|
Unit |
addFocusables(views: ArrayList<View!>!, direction: Int, focusableMode: Int)
Adds any focusable views that are descendants of this view (possibly including this view if it is focusable itself) to views. This method adds all focusable views regardless if we are in touch mode or only views focusable in touch mode if we are in touch mode or only views that can take accessibility focus if accessibility is enabled depending on the focusable mode parameter.
|
Unit |
addKeyboardNavigationClusters(views: MutableCollection<View!>, direction: Int)
Adds any keyboard navigation cluster roots that are descendants of this view (possibly including this view if it is a cluster root itself) to views.
|
Unit |
addOnAttachStateChangeListener(listener: View.OnAttachStateChangeListener!)
Add a listener for attach state changes. This listener will be called whenever this view is attached or detached from a window. Remove the listener using removeOnAttachStateChangeListener(android.view.View.OnAttachStateChangeListener) .
|
Unit |
addOnLayoutChangeListener(listener: View.OnLayoutChangeListener!)
Add a listener that will be called when the bounds of the view change due to layout processing.
|
Unit |
addOnUnhandledKeyEventListener(listener: View.OnUnhandledKeyEventListener!)
Adds a listener which will receive unhandled KeyEvent s. This must be called on the UI thread.
|
Unit |
addTouchables(views: ArrayList<View!>!)
Add any touchable views that are descendants of this view (possibly including this view if it is touchable itself) to views.
|
ViewPropertyAnimator! |
animate()
This method returns a ViewPropertyAnimator object, which can be used to animate specific properties on this View.
|
Unit |
announceForAccessibility(text: CharSequence!)
Convenience method for sending a AccessibilityEvent#TYPE_ANNOUNCEMENT AccessibilityEvent to suggest that an accessibility service announce the specified text to its users.
Note: The event generated with this API carries no semantic meaning, and is appropriate only in exceptional situations. Apps can generally achieve correct behavior for accessibility by accurately supplying the semantics of their UI. They should not need to specify what exactly is announced to users.
In general, only announce transitions and don't generate a confirmation message for simple actions like a button press. Label your controls concisely and precisely instead, and for significant UI changes like window changes, use android.app.Activity#setTitle(CharSequence) and setAccessibilityPaneTitle(java.lang.CharSequence) .
Use setAccessibilityLiveRegion(int) to inform the user of changes to critical views within the user interface. These should still be used sparingly as they may generate announcements every time a View is updated.
For notifying users about errors, such as in a login screen with text that displays an "incorrect password" notification, that view should send an AccessibilityEvent of type AccessibilityEvent#CONTENT_CHANGE_TYPE_ERROR and set AccessibilityNodeInfo#setError(CharSequence) instead. Custom widgets should expose error-setting methods that support accessibility automatically. For example, instead of explicitly sending this event when using a TextView, use android.widget.TextView#setError(CharSequence) .
Use setStateDescription(java.lang.CharSequence) to convey state changes to views within the user interface. While a live region may send different types of events generated by the view, state description will send AccessibilityEvent#TYPE_WINDOW_CONTENT_CHANGED events of type AccessibilityEvent#CONTENT_CHANGE_TYPE_STATE_DESCRIPTION .
|
Unit |
autofill(value: AutofillValue!)
Automatically fills the content of this view with the value .
Views support the Autofill Framework mainly by:
- Providing the metadata defining what the view means and how it can be autofilled.
- Implementing the methods that autofill the view.
onProvideAutofillStructure(android.view.ViewStructure,int) is responsible for the former, this method is responsible for latter.
This method does nothing by default, but when overridden it typically:
- Checks if the provided value matches the expected type (which is defined by
getAutofillType() ).
- Checks if the view is editable - if it isn't, it should return right away.
- Call the proper getter method on
AutofillValue to fetch the actual value.
- Pass the actual value to the equivalent setter in the view.
For example, a text-field view could implement the method this way:
@Override
public void autofill(AutofillValue value) {
if (!value.isText() || !this.isEditable()) {
return;
}
CharSequence text = value.getTextValue();
if (text != null) {
this.setText(text);
}
}
If the value is updated asynchronously, the next call to AutofillManager#notifyValueChanged(View) must happen after the value was changed to the autofilled value. If not, the view will not be considered autofilled.
Note: After this method is called, the value returned by getAutofillValue() must be equal to the value passed to it, otherwise the view will not be highlighted as autofilled.
|
Unit |
autofill(values: SparseArray<AutofillValue!>)
Automatically fills the content of the virtual children within this view.
Views with virtual children support the Autofill Framework mainly by:
- Providing the metadata defining what the virtual children mean and how they can be autofilled.
- Implementing the methods that autofill the virtual children.
onProvideAutofillVirtualStructure(android.view.ViewStructure,int) is responsible for the former, this method is responsible for the latter - see autofill(android.view.autofill.AutofillValue) and onProvideAutofillVirtualStructure(android.view.ViewStructure,int) for more info about autofill.
If a child value is updated asynchronously, the next call to AutofillManager#notifyValueChanged(View, int, AutofillValue) must happen after the value was changed to the autofilled value. If not, the child will not be considered autofilled.
Note: To indicate that a virtual view was autofilled, ?android:attr/autofilledHighlight should be drawn over it until the data changes.
|
Boolean |
awakenScrollBars()
Trigger the scrollbars to draw. When invoked this method starts an animation to fade the scrollbars out after a default delay. If a subclass provides animated scrolling, the start delay should equal the duration of the scrolling animation.
The animation starts only if at least one of the scrollbars is enabled, as specified by isHorizontalScrollBarEnabled() and isVerticalScrollBarEnabled() . When the animation is started, this method returns true, and false otherwise. If the animation is started, this method calls invalidate() ; in that case the caller should not call invalidate() .
This method should be invoked every time a subclass directly updates the scroll parameters.
This method is automatically invoked by scrollBy(int,int) and scrollTo(int,int) .
|
Boolean |
awakenScrollBars(startDelay: Int)
Trigger the scrollbars to draw. When invoked this method starts an animation to fade the scrollbars out after a fixed delay. If a subclass provides animated scrolling, the start delay should equal the duration of the scrolling animation.
The animation starts only if at least one of the scrollbars is enabled, as specified by isHorizontalScrollBarEnabled() and isVerticalScrollBarEnabled() . When the animation is started, this method returns true, and false otherwise. If the animation is started, this method calls invalidate() ; in that case the caller should not call invalidate() .
This method should be invoked every time a subclass directly updates the scroll parameters.
|
Boolean |
awakenScrollBars(startDelay: Int, invalidate: Boolean)
Trigger the scrollbars to draw. When invoked this method starts an animation to fade the scrollbars out after a fixed delay. If a subclass provides animated scrolling, the start delay should equal the duration of the scrolling animation.
The animation starts only if at least one of the scrollbars is enabled, as specified by isHorizontalScrollBarEnabled() and isVerticalScrollBarEnabled() . When the animation is started, this method returns true, and false otherwise. If the animation is started, this method calls invalidate() if the invalidate parameter is set to true; in that case the caller should not call invalidate() .
This method should be invoked every time a subclass directly updates the scroll parameters.
|
Unit |
bringToFront()
Change the view's z order in the tree, so it's on top of other sibling views. This ordering change may affect layout, if the parent container uses an order-dependent layout scheme (e.g., LinearLayout). Prior to android.os.Build.VERSION_CODES#KITKAT this method should be followed by calls to requestLayout() and View#invalidate() on the view's parent to force the parent to redraw with the new child ordering.
|
Unit |
buildDrawingCache()
Calling this method is equivalent to calling buildDrawingCache(false) .
|
Unit |
buildDrawingCache(autoScale: Boolean)
Forces the drawing cache to be built if the drawing cache is invalid.
If you call buildDrawingCache() manually without calling setDrawingCacheEnabled(true) , you should cleanup the cache by calling destroyDrawingCache() afterwards.
Note about auto scaling in compatibility mode: When auto scaling is not enabled, this method will create a bitmap of the same size as this view. Because this bitmap will be drawn scaled by the parent ViewGroup, the result on screen might show scaling artifacts. To avoid such artifacts, you should call this method by setting the auto scaling to true. Doing so, however, will generate a bitmap of a different size than the view. This implies that your application must be able to handle this size.
You should avoid calling this method when hardware acceleration is enabled. If you do not need the drawing cache bitmap, calling this method will increase memory usage and cause the view to be rendered in software once, thus negatively impacting performance.
|
Unit |
buildLayer()
Forces this view's layer to be created and this view to be rendered into its layer. If this view's layer type is set to LAYER_TYPE_NONE , invoking this method will have no effect. This method can for instance be used to render a view into its layer before starting an animation. If this view is complex, rendering into the layer before starting the animation will avoid skipping frames.
|
Boolean |
callOnClick()
Directly call any attached OnClickListener. Unlike performClick() , this only calls the listener, and does not do any associated clicking actions like reporting an accessibility event.
|
Boolean |
canResolveLayoutDirection()
Check if layout direction resolution can be done.
|
Boolean |
canResolveTextAlignment()
Check if text alignment resolution can be done.
|
Boolean |
canResolveTextDirection()
Check if text direction resolution can be done.
|
Boolean |
canScrollHorizontally(direction: Int)
Check if this view can be scrolled horizontally in a certain direction.
This is without regard to whether the view is enabled or not, or if it will scroll in response to user input or not.
|
Boolean |
canScrollVertically(direction: Int)
Check if this view can be scrolled vertically in a certain direction.
This is without regard to whether the view is enabled or not, or if it will scroll in response to user input or not.
|
Unit |
cancelDragAndDrop()
Cancels an ongoing drag and drop operation.
A android.view.DragEvent object with android.view.DragEvent#getAction() value of android.view.DragEvent#ACTION_DRAG_ENDED and android.view.DragEvent#getResult() value of false will be sent to every View that received android.view.DragEvent#ACTION_DRAG_STARTED even if they are not currently visible.
This method can be called on any View in the same window as the View on which startDragAndDrop was called.
|
Unit |
cancelLongPress()
Cancels a pending long press. Your subclass can use this if you want the context menu to come up if the user presses and holds at the same place, but you don't want it to come up if they press and then move around enough to cause scrolling.
|
Unit |
cancelPendingInputEvents()
Cancel any deferred high-level input events that were previously posted to the event queue.
Many views post high-level events such as click handlers to the event queue to run deferred in order to preserve a desired user experience - clearing visible pressed states before executing, etc. This method will abort any events of this nature that are currently in flight.
Custom views that generate their own high-level deferred input events should override onCancelPendingInputEvents() and remove those pending events from the queue.
This will also cancel pending input events for any child views.
Note that this may not be sufficient as a debouncing strategy for clicks in all cases. This will not impact newer events posted after this call that may occur as a result of lower-level input events still waiting in the queue. If you are trying to prevent double-submitted events for the duration of some sort of asynchronous transaction you should also take other steps to protect against unexpected double inputs e.g. calling setEnabled(false) and re-enabling the view when the transaction completes, tracking already submitted transaction IDs, etc.
|
Boolean |
checkInputConnectionProxy(view: View!)
Called by the android.view.inputmethod.InputMethodManager when a view who is not the current input connection target is trying to make a call on the manager. The default implementation returns false; you can override this to return true for certain views if you are performing InputConnection proxying to them.
|
Unit |
clearAnimation()
Cancels any animations for this view.
|
Unit |
clearFocus()
Called when this view wants to give up focus. If focus is cleared onFocusChanged(boolean,int,android.graphics.Rect) is called.
Note: When not in touch-mode, the framework will try to give focus to the first focusable View from the top after focus is cleared. Hence, if this View is the first from the top that can take focus, then all callbacks related to clearing focus will be invoked after which the framework will give focus to this view.
|
Unit |
clearPendingCredentialRequest()
Clears the request and callback previously set through View#setPendingCredentialRequest . Once this API is invoked, there will be no request fired to CredentialManager on future view focus events.
|
Unit |
clearViewTranslationCallback()
Clear the ViewTranslationCallback from this view.
|
Int |
combineMeasuredStates(curState: Int, newState: Int)
Merge two states as returned by getMeasuredState() .
|
Int |
computeHorizontalScrollExtent()
Compute the horizontal extent of the horizontal scrollbar's thumb within the horizontal range. This value is used to compute the length of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the units used by computeHorizontalScrollRange() and computeHorizontalScrollOffset() .
The default extent is the drawing width of this view.
|
Int |
computeHorizontalScrollOffset()
Compute the horizontal offset of the horizontal scrollbar's thumb within the horizontal range. This value is used to compute the position of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the units used by computeHorizontalScrollRange() and computeHorizontalScrollExtent() .
The default offset is the scroll offset of this view.
|
Int |
computeHorizontalScrollRange()
Compute the horizontal range that the horizontal scrollbar represents.
The range is expressed in arbitrary units that must be the same as the units used by computeHorizontalScrollExtent() and computeHorizontalScrollOffset() .
The default range is the drawing width of this view.
|
Unit |
computeScroll()
Called by a parent to request that a child update its values for mScrollX and mScrollY if necessary. This will typically be done if the child is animating a scroll using a Scroller object.
|
WindowInsets! |
computeSystemWindowInsets(in: WindowInsets!, outLocalInsets: Rect!)
Compute insets that should be consumed by this view and the ones that should propagate to those under it.
|
Int |
computeVerticalScrollExtent()
Compute the vertical extent of the vertical scrollbar's thumb within the vertical range. This value is used to compute the length of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the units used by computeVerticalScrollRange() and computeVerticalScrollOffset() .
The default extent is the drawing height of this view.
|
Int |
computeVerticalScrollOffset()
Compute the vertical offset of the vertical scrollbar's thumb within the horizontal range. This value is used to compute the position of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the units used by computeVerticalScrollRange() and computeVerticalScrollExtent() .
The default offset is the scroll offset of this view.
|
Int |
computeVerticalScrollRange()
Compute the vertical range that the vertical scrollbar represents.
The range is expressed in arbitrary units that must be the same as the units used by computeVerticalScrollExtent() and computeVerticalScrollOffset() .
|
AccessibilityNodeInfo! |
createAccessibilityNodeInfo()
Returns an AccessibilityNodeInfo representing this view from the point of view of an android.accessibilityservice.AccessibilityService . This method is responsible for obtaining an accessibility node info from a pool of reusable instances and calling onInitializeAccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) on this view to initialize the former.
Note: The client is responsible for recycling the obtained instance by calling AccessibilityNodeInfo#recycle() to minimize object creation.
|
Unit |
createContextMenu(menu: ContextMenu!)
Show the context menu for this view. It is not safe to hold on to the menu after returning from this method. You should normally not overload this method. Overload onCreateContextMenu(android.view.ContextMenu) or define an OnCreateContextMenuListener to add items to the context menu.
|
Unit |
destroyDrawingCache()
Frees the resources used by the drawing cache. If you call buildDrawingCache() manually without calling setDrawingCacheEnabled(true) , you should cleanup the cache with this method afterwards.
|
WindowInsets! |
dispatchApplyWindowInsets(insets: WindowInsets!)
Request to apply the given window insets to this view or another view in its subtree.
This method should be called by clients wishing to apply insets corresponding to areas obscured by window decorations or overlays. This can include the status and navigation bars, action bars, input methods and more. New inset categories may be added in the future. The method returns the insets provided minus any that were applied by this view or its children.
Clients wishing to provide custom behavior should override the onApplyWindowInsets(android.view.WindowInsets) method or alternatively provide a OnApplyWindowInsetsListener via the setOnApplyWindowInsetsListener method.
This method replaces the older fitSystemWindows method.
|
Boolean |
dispatchCapturedPointerEvent(event: MotionEvent!)
Pass a captured pointer event down to the focused view.
|
Unit |
dispatchConfigurationChanged(newConfig: Configuration!)
Dispatch a notification about a resource configuration change down the view hierarchy. ViewGroups should override to route to their children.
|
Unit |
dispatchCreateViewTranslationRequest(viewIds: MutableMap<AutofillId!, LongArray!>, supportedFormats: IntArray, capability: TranslationCapability, requests: MutableList<ViewTranslationRequest!>)
Dispatch to collect the ViewTranslationRequest s for translation purpose by traversing the hierarchy when the app requests ui translation. Typically, this method should only be overridden by subclasses that provide a view hierarchy (such as ViewGroup ). Other classes should override View#onCreateViewTranslationRequest for normal view or override View#onVirtualViewTranslationResponses for view contains virtual children. When requested to start the ui translation, the system will call this method to traverse the view hierarchy to collect ViewTranslationRequest s and create a android.view.translation.Translator to translate the requests. All the ViewTranslationRequest s must be added when the traversal is done.
The default implementation calls View#onCreateViewTranslationRequest for normal view or calls View#onVirtualViewTranslationResponses for view contains virtual children to build ViewTranslationRequest if the view should be translated. The view is marked as having transient state so that recycling of views doesn't prevent the system from attaching the response to it. Therefore, if overriding this method, you should set or reset the transient state.
|
Unit |
dispatchDisplayHint(hint: Int)
Dispatch a hint about whether this view is displayed. For instance, when a View moves out of the screen, it might receives a display hint indicating the view is not displayed. Applications should not rely on this hint as there is no guarantee that they will receive one.
|
Boolean |
dispatchDragEvent(event: DragEvent!)
Detects if this View is enabled and has a drag event listener. If both are true, then it calls the drag event listener with the android.view.DragEvent it received. If the drag event listener returns true , then dispatchDragEvent() returns true .
For all other cases, the method calls the onDragEvent() drag event handler method and returns its result.
This ensures that a drag event is always consumed, even if the View does not have a drag event listener. However, if the View has a listener and the listener returns true, then onDragEvent() is not called.
|
Unit |
dispatchDraw(canvas: Canvas)
Called by draw to draw the child views. This may be overridden by derived classes to gain control just before its children are drawn (but after its own view has been drawn).
|
Unit |
dispatchDrawableHotspotChanged(x: Float, y: Float)
Dispatches drawableHotspotChanged to all of this View's children.
|
Unit |
dispatchFinishTemporaryDetach()
Dispatch onFinishTemporaryDetach() to this View and its direct children if this is a container View. If you override this method you must call through to the superclass implementation.
|
Boolean |
dispatchGenericFocusedEvent(event: MotionEvent!)
Dispatch a generic motion event to the currently focused view.
Do not call this method directly. Call dispatchGenericMotionEvent(android.view.MotionEvent) instead.
|
Boolean |
dispatchGenericMotionEvent(event: MotionEvent!)
Dispatch a generic motion event.
Generic motion events with source class InputDevice#SOURCE_CLASS_POINTER are delivered to the view under the pointer. All other generic motion events are delivered to the focused view. Hover events are handled specially and are delivered to onHoverEvent(android.view.MotionEvent) first.
|
Boolean |
dispatchGenericPointerEvent(event: MotionEvent!)
Dispatch a generic motion event to the view under the first pointer.
Do not call this method directly. Call dispatchGenericMotionEvent(android.view.MotionEvent) instead.
|
Boolean |
dispatchHoverEvent(event: MotionEvent!)
Dispatch a hover event.
Do not call this method directly. Call dispatchGenericMotionEvent(android.view.MotionEvent) instead.
|
Boolean |
dispatchKeyEvent(event: KeyEvent!)
Dispatch a key event to the next view on the focus path. This path runs from the top of the view tree down to the currently focused view. If this view has focus, it will dispatch to itself. Otherwise it will dispatch the next node down the focus path. This method also fires any key listeners.
|
Boolean |
dispatchKeyEventPreIme(event: KeyEvent!)
Dispatch a key event before it is processed by any input method associated with the view hierarchy. This can be used to intercept key events in special situations before the IME consumes them; a typical example would be handling the BACK key to update the application's UI instead of allowing the IME to see it and close itself.
|
Boolean |
dispatchKeyShortcutEvent(event: KeyEvent!)
Dispatches a key shortcut event.
|
Boolean |
dispatchNestedFling(velocityX: Float, velocityY: Float, consumed: Boolean)
Dispatch a fling to a nested scrolling parent.
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.
|
Boolean |
dispatchNestedPreFling(velocityX: Float, velocityY: Float)
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 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:
- If a custom view is paged and needs to settle to a fixed page-point, do not call
dispatchNestedPreFling ; consume the fling and settle to a valid position 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 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.
|
Boolean |
dispatchNestedPrePerformAccessibilityAction(action: Int, arguments: Bundle?)
Report an accessibility action to this view's parents for delegated processing.
Implementations of performAccessibilityAction(int,android.os.Bundle) may internally call this method to delegate an accessibility action to a supporting parent. If the parent returns true from its ViewParent#onNestedPrePerformAccessibilityAction(View, int, android.os.Bundle) method this method will return true to signify that the action was consumed.
This method is useful for implementing nested scrolling child views. If isNestedScrollingEnabled() returns true and the action is a scrolling action a custom view implementation may invoke this method to allow a parent to consume the scroll first. If this method returns true the custom view should skip its own scrolling behavior.
|
Boolean |
dispatchNestedPreScroll(dx: Int, dy: Int, consumed: IntArray?, offsetInWindow: IntArray?)
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 nested scrolling operation to consume some or all of the scroll operation before the child view consumes it.
|
Boolean |
dispatchNestedScroll(dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int, offsetInWindow: IntArray?)
Dispatch one step of a nested scroll in progress.
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.
|
Unit |
dispatchPointerCaptureChanged(hasCapture: Boolean)
|
Boolean |
dispatchPopulateAccessibilityEvent(event: AccessibilityEvent!)
Dispatches an AccessibilityEvent to the View to add the text content of the view and its children.
Note: This method should only be used with event.setText(). Avoid mutating other event state in this method. In general, put UI metadata in the node for services to easily query.
- If you are modifying other event properties, you may be eliminating semantics accessibility services may want. Instead, send a separate event using
sendAccessibilityEvent(int) and override onInitializeAccessibilityEvent(android.view.accessibility.AccessibilityEvent) .
- If you are checking for type
AccessibilityEvent#TYPE_WINDOW_STATE_CHANGED to generate window/title announcements, you may be causing disruptive announcements (or making no announcements at all). Instead, follow the practices described in View#announceForAccessibility(CharSequence) . Note: this does not suggest calling announceForAccessibility(), but using the suggestions listed in its documentation.
- If you are making changes based on the state of accessibility, such as checking for an event type to trigger a UI update, while well-intentioned, you are creating brittle, less well-maintained code that works for some users but not others. Instead, leverage existing code for equitable experiences and less technical debt. See
AccessibilityManager#isEnabled() for an example.
Note that the event text is populated in a separate dispatch path (onPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent) ) since we add to the event not only the text of the source but also the text of all its descendants.
A typical implementation will call onPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent) on this view and then call the dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent) on each child or the first child that is visible. Override this method if custom population of the event text content is required.
If an AccessibilityDelegate has been specified via calling setAccessibilityDelegate(android.view.View.AccessibilityDelegate) its AccessibilityDelegate#dispatchPopulateAccessibilityEvent(View, AccessibilityEvent) is responsible for handling this call.
If this view sets isAccessibilityDataSensitive() then this view should only append sensitive information to an event that also sets AccessibilityEvent#isAccessibilityDataSensitive() .
Note: Accessibility events of certain types are not dispatched for populating the event text via this method. For details refer to AccessibilityEvent .
|
Unit |
dispatchProvideAutofillStructure(structure: ViewStructure, flags: Int)
Dispatches creation of a ViewStructure s for autofill purposes down the hierarchy, when an Assist structure is being created as part of an autofill request.
The default implementation does the following:
Typically, this method should only be overridden by subclasses that provide a view hierarchy (such as ViewGroup ) - other classes should override onProvideAutofillStructure(android.view.ViewStructure,int) or onProvideAutofillVirtualStructure(android.view.ViewStructure,int) instead.
When overridden, it must:
- Either call
super.dispatchProvideAutofillStructure(structure, flags) or explicitly set the AutofillId in the structure (for example, by calling structure.setAutofillId(getAutofillId()) ).
- Decide how to handle the
AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS flag - when set, all views in the structure should be considered important for autofill, regardless of what isImportantForAutofill() returns. We encourage you to respect this flag to provide a better user experience - this flag is typically used when an user explicitly requested autofill. If the flag is not set, then only views marked as important for autofill should be included in the structure - skipping non-important views optimizes the overall autofill performance.
|
Unit |
dispatchProvideStructure(structure: ViewStructure!)
Dispatch creation of ViewStructure down the hierarchy. The default implementation calls onProvideStructure and onProvideVirtualStructure .
|
Unit |
dispatchRestoreInstanceState(container: SparseArray<Parcelable!>!)
Called by restoreHierarchyState(android.util.SparseArray) to retrieve the state for this view and its children. May be overridden to modify how restoring happens to a view's children; for example, some views may want to not store state for their children.
|
Unit |
dispatchSaveInstanceState(container: SparseArray<Parcelable!>!)
Called by saveHierarchyState(android.util.SparseArray) to store the state for this view and its children. May be overridden to modify how freezing happens to a view's children; for example, some views may want to not store state for their children.
|
Unit |
dispatchScrollCaptureSearch(localVisibleRect: Rect, windowOffset: Point, targets: Consumer<ScrollCaptureTarget!>)
Dispatch a scroll capture search request down the view hierarchy.
|
Unit |
dispatchSetActivated(activated: Boolean)
Dispatch setActivated to all of this View's children.
|
Unit |
dispatchSetPressed(pressed: Boolean)
Dispatch setPressed to all of this View's children.
|
Unit |
dispatchSetSelected(selected: Boolean)
Dispatch setSelected to all of this View's children.
|
Unit |
dispatchStartTemporaryDetach()
Dispatch onStartTemporaryDetach() to this View and its direct children if this is a container View. If you override this method you must call through to the superclass implementation.
|
Unit |
dispatchSystemUiVisibilityChanged(visibility: Int)
Dispatch callbacks to setOnSystemUiVisibilityChangeListener down the view hierarchy.
|
Boolean |
dispatchTouchEvent(event: MotionEvent!)
Pass the touch screen motion event down to the target view, or this view if it is the target.
|
Boolean |
dispatchTrackballEvent(event: MotionEvent!)
Pass a trackball motion event down to the focused view.
|
Boolean |
dispatchUnhandledMove(focused: View!, direction: Int)
This method is the last chance for the focused view and its ancestors to respond to an arrow key. This is called when the focused view did not consume the key internally, nor could the view system find a new view in the requested direction to give focus to.
|
Unit |
dispatchVisibilityChanged(changedView: View, visibility: Int)
Dispatch a view visibility change down the view hierarchy. ViewGroups should override to route to their children.
|
Unit |
dispatchWindowFocusChanged(hasFocus: Boolean)
Called when the window containing this view gains or loses window focus. ViewGroups should override to route to their children.
|
Unit |
dispatchWindowInsetsAnimationEnd(animation: WindowInsetsAnimation)
Dispatches WindowInsetsAnimation.Callback#onEnd(WindowInsetsAnimation) when Window Insets animation ends.
|
Unit |
dispatchWindowInsetsAnimationPrepare(animation: WindowInsetsAnimation)
Dispatches WindowInsetsAnimation.Callback#onPrepare(WindowInsetsAnimation) when Window Insets animation is being prepared.
|
WindowInsets |
dispatchWindowInsetsAnimationProgress(insets: WindowInsets, runningAnimations: MutableList<WindowInsetsAnimation!>)
Dispatches WindowInsetsAnimation.Callback#onProgress(WindowInsets, List) when Window Insets animation makes progress.
|
WindowInsetsAnimation.Bounds |
dispatchWindowInsetsAnimationStart(animation: WindowInsetsAnimation, bounds: WindowInsetsAnimation.Bounds)
Dispatches WindowInsetsAnimation.Callback#onStart(WindowInsetsAnimation, Bounds) when Window Insets animation is started.
|
Unit |
dispatchWindowSystemUiVisiblityChanged(visible: Int)
Dispatch callbacks to onWindowSystemUiVisibilityChanged(int) down the view hierarchy.
|
Unit |
dispatchWindowVisibilityChanged(visibility: Int)
Dispatch a window visibility change down the view hierarchy. ViewGroups should override to route to their children.
|
Unit |
draw(canvas: Canvas)
Manually render this view (and all of its children) to the given Canvas. The view must have already done a full layout before this function is called. When implementing a view, implement onDraw(android.graphics.Canvas) instead of overriding this method. If you do need to override this method, call the superclass version. If you override this method you must call through to the superclass implementation.
|
View! |
findFocus()
Find the view in the hierarchy rooted at this view that currently has focus.
|
OnBackInvokedDispatcher? |
findOnBackInvokedDispatcher()
Walk up the View hierarchy to find the nearest OnBackInvokedDispatcher .
|
T |
findViewById(id: Int)
Finds the first descendant view with the given ID, the view itself if the ID matches getId() , or null if the ID is invalid (< 0) or there is 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. If the target class type is unconstrained, an explicit cast may be necessary.
|
T |
findViewWithTag(tag: Any!)
Look for a child view with the given tag. If this view has the given tag, return this view.
|
Unit |
findViewsWithText(outViews: ArrayList<View!>!, searched: CharSequence!, flags: Int)
Finds the Views that contain given text. The containment is case insensitive. The search is performed by either the text that the View renders or the content description that describes the view for accessibility purposes and the view does not render or both. Clients can specify how the search is to be performed via passing the FIND_VIEWS_WITH_TEXT and FIND_VIEWS_WITH_CONTENT_DESCRIPTION flags.
|
Boolean |
fitSystemWindows(insets: Rect!)
Called by the view hierarchy when the content insets for a window have changed, to allow it to adjust its content to fit within those windows. The content insets tell you the space that the status bar, input method, and other system windows infringe on the application's window.
You do not normally need to deal with this function, since the default window decoration given to applications takes care of applying it to the content of the window. If you use SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION this will not be the case, and your content can be placed under those system elements. You can then use this method within your view hierarchy if you have parts of your UI which you would like to ensure are not being covered.
The default implementation of this method simply applies the content insets to the view's padding, consuming that content (modifying the insets to be 0), and returning true. This behavior is off by default, but can be enabled through setFitsSystemWindows(boolean) .
This function's traversal down the hierarchy is depth-first. The same content insets object is propagated down the hierarchy, so any changes made to it will be seen by all following views (including potentially ones above in the hierarchy since this is a depth-first traversal). The first view that returns true will abort the entire traversal.
The default implementation works well for a situation where it is used with a container that covers the entire window, allowing it to apply the appropriate insets to its content on all edges. If you need a more complicated layout (such as two different views fitting system windows, one on the top of the window, and one on the bottom), you can override the method and handle the insets however you would like. Note that the insets provided by the framework are always relative to the far edges of the window, not accounting for the location of the called view within that window. (In fact when this method is called you do not yet know where the layout will place the view, as it is done before layout happens.)
Note: unlike many View methods, there is no dispatch phase to this call. If you are overriding it in a ViewGroup and want to allow the call to continue to your children, you must be sure to call the super implementation.
Here is a sample layout that makes use of fitting system windows to have controls for a video view placed inside of the window decorations that it hides and shows. This can be used with code like the second sample (video player) shown in setSystemUiVisibility(int) .
|
View! |
focusSearch(direction: Int)
Find the nearest view in the specified direction that can take focus. This does not actually give focus to that view.
|
Unit |
forceHasOverlappingRendering(hasOverlappingRendering: Boolean)
Sets the behavior for overlapping rendering for this view (see hasOverlappingRendering() for more details on this behavior). Calling this method is an alternative to overriding hasOverlappingRendering() in a subclass, providing the value which is then used internally. That is, when forceHasOverlappingRendering(boolean) is called, the value of hasOverlappingRendering() is ignored and the value passed into this method is used instead.
|
Unit |
forceLayout()
Forces this view to be laid out during the next layout pass. This method does not call requestLayout() or forceLayout() on the parent.
|
Boolean |
gatherTransparentRegion(region: Region?)
This is used by the ViewRoot to perform an optimization when the view hierarchy contains one or several SurfaceView. SurfaceView is always considered transparent, but its children are not, therefore all View objects remove themselves from the global transparent region (passed as a parameter to this function).
|
Unit |
generateDisplayHash(hashAlgorithm: String, bounds: Rect?, executor: Executor, callback: DisplayHashResultCallback)
Called to generate a DisplayHash for this view.
|
Int |
generateViewId()
Generate a value suitable for use in setId(int) . This value will not collide with ID values generated at build time by aapt for R.id.
|
View.AccessibilityDelegate! |
getAccessibilityDelegate()
Returns the delegate for implementing accessibility support via composition. For more details see AccessibilityDelegate .
|
Int |
getAccessibilityLiveRegion()
Gets the live region mode for this View.
|
AccessibilityNodeProvider! |
getAccessibilityNodeProvider()
Gets the provider for managing a virtual view hierarchy rooted at this View and reported to android.accessibilityservice.AccessibilityService s that explore the window content.
If this method returns an instance, this instance is responsible for managing AccessibilityNodeInfo 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 AccessibilityDelegate has been specified via calling setAccessibilityDelegate(android.view.View.AccessibilityDelegate) its AccessibilityDelegate#getAccessibilityNodeProvider(View) is responsible for handling this call.
|
CharSequence? |
getAccessibilityPaneTitle()
Get the title of the pane for purposes of accessibility.
|
Int |
getAccessibilityTraversalAfter()
Gets the id of a view after which this one is visited in accessibility traversal.
|
Int |
getAccessibilityTraversalBefore()
Gets the id of a view before which this one is visited in accessibility traversal.
|
String? |
getAllowedHandwritingDelegatePackageName()
Returns the allowed package for delegate editor views for which this view may act as a handwriting delegator, as set by setAllowedHandwritingDelegatePackage . If setAllowedHandwritingDelegatePackage has not been called, or called with null argument, this will return null , meaning that this delegator view may only be used to initiate handwriting mode for a delegate editor view from the same package as this delegator view.
|
String? |
getAllowedHandwritingDelegatorPackageName()
Returns the allowed package for views which may act as a handwriting delegator for this delegate editor view, as set by setAllowedHandwritingDelegatorPackage . If setAllowedHandwritingDelegatorPackage has not been called, or called with null argument, this will return null , meaning that only views from the same package as this delegator editor view may act as a handwriting delegator.
|
Float |
getAlpha()
The opacity of the view. This is a value from 0 to 1, where 0 means the view is completely transparent and 1 means the view is completely opaque.
By default this is 1.0f.
|
Animation! |
getAnimation()
Get the animation currently associated with this view.
|
Matrix? |
getAnimationMatrix()
Return the current transformation matrix of the view. This is used in animation frameworks, such as android.transition.Transition . Returns null when there is no transformation provided by setAnimationMatrix(android.graphics.Matrix) . Application developers should use transformation methods like setRotation(float) , setScaleX(float) , setScaleX(float) , setTranslationX(float) } and setTranslationY(float) (float)}} instead.
|
IBinder! |
getApplicationWindowToken()
Retrieve a unique token identifying the top-level "real" window of the window that this view is attached to. That is, this is like getWindowToken , except if the window this view in is a panel window (attached to another containing window), then the token of the containing window is returned instead.
|
IntArray |
getAttributeResolutionStack(attribute: Int)
Returns the ordered list of resource ID that are considered when resolving attribute values for this View . The list will include layout resource ID if the View is inflated from XML. It will also include a set of explicit styles if specified in XML using style="..." . Finally, it will include the default styles resolved from the theme.
Note: this method will only return actual values if the view attribute debugging is enabled in Android developer options.
|
MutableMap<Int!, Int!> |
getAttributeSourceResourceMap()
Returns the mapping of attribute resource ID to source resource ID where the attribute value was set. Source resource ID can either be a layout resource ID, if the value was set in XML within the View tag, or a style resource ID, if the attribute was set in a style. The source resource value will be one of the resource IDs from getAttributeSourceResourceMap() .
Note: this method will only return actual values if the view attribute debugging is enabled in Android developer options.
|
Array<String!>? |
getAutofillHints()
Gets the hints that help an android.service.autofill.AutofillService determine how to autofill the view with the user's data.
See setAutofillHints(java.lang.String...) for more info about these hints.
|
AutofillId! |
getAutofillId()
Gets the unique, logical identifier of this view in the activity, for autofill purposes.
The autofill id is created on demand, unless it is explicitly set by setAutofillId(android.view.autofill.AutofillId) .
See setAutofillId(android.view.autofill.AutofillId) for more info.
|
Int |
getAutofillType()
Describes the autofill type of this view, so an android.service.autofill.AutofillService can create the proper AutofillValue when autofilling the view.
By default returns AUTOFILL_TYPE_NONE , but views should override it to properly support the Autofill Framework.
|
AutofillValue? |
getAutofillValue()
Gets the View 's current autofill value.
By default returns null , but subclasses should override it and return an appropriate value to properly support the Autofill Framework.
|
Drawable! |
getBackground()
Gets the background drawable
|
BlendMode? |
getBackgroundTintBlendMode()
Return the blending mode used to apply the tint to the background drawable, if specified.
|
ColorStateList? |
getBackgroundTintList()
Return the tint applied to the background drawable, if specified.
|
PorterDuff.Mode? |
getBackgroundTintMode()
Return the blending mode used to apply the tint to the background drawable, if specified.
|
Int |
getBottom()
Bottom position of this view relative to its parent.
|
Float |
getBottomFadingEdgeStrength()
Returns the strength, or intensity, of the bottom faded edge. The strength is a value between 0.0 (no fade) and 1.0 (full fade). The default implementation returns 0.0 or 1.0 but no value in between. Subclasses should override this method to provide a smoother fade transition when scrolling occurs.
|
Int |
getBottomPaddingOffset()
Amount by which to extend the bottom fading region. Called only when isPaddingOffsetRequired() returns true.
|
Float |
getCameraDistance()
Gets the distance along the Z axis from the camera to this view.
|
Rect! |
getClipBounds()
Returns a copy of the current clipBounds .
|
Boolean |
getClipBounds(outRect: Rect!)
Populates an output rectangle with the clip bounds of the view, returning true if successful or false if the view's clip bounds are null .
|
Boolean |
getClipToOutline()
Returns whether the Outline should be used to clip the contents of the View.
Note that this flag will only be respected if the View's Outline returns true from Outline#canClip() .
|
ContentCaptureSession? |
getContentCaptureSession()
Gets the session used to notify content capture events.
|
CharSequence! |
getContentDescription()
Returns the View 's content description.
Note: Do not override this method, as it will have no effect on the content description presented to accessibility services. You must call setContentDescription(java.lang.CharSequence) to modify the content description.
|
Int |
getContentSensitivity()
Gets content sensitivity mode to determine whether this view displays sensitive content.
See setContentSensitivity(int) and isContentSensitive() for more info about this mode.
|
Context! |
getContext()
Returns the context the view is running in, through which it can access the current theme, resources, etc.
|
ContextMenu.ContextMenuInfo! |
getContextMenuInfo()
Views should implement this if they have extra information to associate with the context menu. The return result is supplied as a parameter to the OnCreateContextMenuListener#onCreateContextMenu(ContextMenu, View, ContextMenuInfo) callback.
|
Boolean |
getDefaultFocusHighlightEnabled()
Returns whether this View should use a default focus highlight when it gets focused but doesn't have android.R.attr#state_focused defined in its background.
|
Int |
getDefaultSize(size: Int, measureSpec: Int)
Utility to return a default size. Uses the supplied size if the MeasureSpec imposed no constraints. Will get larger if allowed by the MeasureSpec.
|
Display! |
getDisplay()
Gets the logical display to which the view's window has been attached.
|
IntArray! |
getDrawableState()
Return an array of resource IDs of the drawable states representing the current state of the view.
|
Bitmap! |
getDrawingCache()
Calling this method is equivalent to calling getDrawingCache(false) .
|
Bitmap! |
getDrawingCache(autoScale: Boolean)
Returns the bitmap in which this view drawing is cached. The returned bitmap is null when caching is disabled. If caching is enabled and the cache is not ready, this method will create it. Calling draw(android.graphics.Canvas) will not draw from the cache when the cache is enabled. To benefit from the cache, you must request the drawing cache by calling this method and draw it on screen if the returned bitmap is not null.
Note about auto scaling in compatibility mode: When auto scaling is not enabled, this method will create a bitmap of the same size as this view. Because this bitmap will be drawn scaled by the parent ViewGroup, the result on screen might show scaling artifacts. To avoid such artifacts, you should call this method by setting the auto scaling to true. Doing so, however, will generate a bitmap of a different size than the view. This implies that your application must be able to handle this size.
|
Int |
getDrawingCacheBackgroundColor()
|
Int |
getDrawingCacheQuality()
Returns the quality of the drawing cache.
|
Unit |
getDrawingRect(outRect: Rect!)
Return the visible drawing bounds of your view. Fills in the output rectangle with the values from getScrollX(), getScrollY(), getWidth(), and getHeight(). These bounds do not account for any transformation properties currently set on the view, such as setScaleX(float) or setRotation(float) .
|
Long |
getDrawingTime()
Return the time at which the drawing of the view hierarchy started.
|
Float |
getElevation()
The base elevation of this view relative to its parent, in pixels.
|
Int |
getExplicitStyle()
Returns the resource ID for the style specified using style="..." in the AttributeSet 's backing XML element or Resources#ID_NULL otherwise if not specified or otherwise not applicable.
Each View can have an explicit style specified in the layout file. This style is used first during the View attribute resolution, then if an attribute is not defined there the resource system looks at default style and theme as fallbacks.
Note: this method will only return actual values if the view attribute debugging is enabled in Android developer options.
|
Boolean |
getFilterTouchesWhenObscured()
Gets whether the framework should discard touches when the view's window is obscured by another visible window at the touched location. Refer to the View security documentation for more details.
|
Boolean |
getFitsSystemWindows()
Check for state of setFitsSystemWindows(boolean) . If this method returns true , the default implementation of fitSystemWindows(android.graphics.Rect) will be executed.
|
Int |
getFocusable()
Returns the focusable setting for this view.
|
ArrayList<View!>! |
getFocusables(direction: Int)
Find and return all focusable views that are descendants of this view, possibly including this view if it is focusable itself.
|
Unit |
getFocusedRect(r: Rect!)
When a view has focus and the user navigates away from it, the next view is searched for starting from the rectangle filled in by this method. By default, the rectangle is the getDrawingRect(android.graphics.Rect) ) of the view. However, if your view maintains some idea of internal selection, such as a cursor, or a selected row or column, you should override this method and fill in a more specific rectangle.
|
Drawable! |
getForeground()
Returns the drawable used as the foreground of this View. The foreground drawable, if non-null, is always drawn on top of the view's content.
|
Int |
getForegroundGravity()
Describes how the foreground is positioned.
|
BlendMode? |
getForegroundTintBlendMode()
Return the blending mode used to apply the tint to the foreground drawable, if specified.
|
ColorStateList? |
getForegroundTintList()
Return the tint applied to the foreground drawable, if specified.
|
PorterDuff.Mode? |
getForegroundTintMode()
Return the blending mode used to apply the tint to the foreground drawable, if specified.
|
Float |
getFrameContentVelocity()
Get the current velocity of the View. The value should always be greater than or equal to 0. Note that this is only valid till the next drawn frame.
|
Boolean |
getGlobalVisibleRect(r: Rect!, globalOffset: Point!)
Sets r to the coordinates of the non-clipped area of this view in the coordinate space of the view's root view. Sets globalOffset to the offset of the view's x and y coordinates from the coordinate space origin, which is the top left corner of the root view irrespective of screen decorations and system UI elements.
To convert r to coordinates relative to the top left corner of this view (without taking view rotations into account), offset r by the inverse values of globalOffset —r.offset(-globalOffset.x, -globalOffset.y) —which is equivalent to calling getLocalVisibleRect(Rect) .
Note: Do not use this method to determine the size of a window in multi-window mode; use WindowManager#getCurrentWindowMetrics() .
|
Boolean |
getGlobalVisibleRect(r: Rect!)
Sets r to the coordinates of the non-clipped area of this view in the coordinate space of the view's root view.
See getGlobalVisibleRect(Rect, Point) for more information.
|
Handler! |
getHandler()
|
Float |
getHandwritingBoundsOffsetBottom()
Return the amount of offset applied to the bottom edge of this view's handwriting bounds, in the unit of pixel.
|
Float |
getHandwritingBoundsOffsetLeft()
Return the amount of offset applied to the left edge of this view's handwriting bounds, in the unit of pixel.
|
Float |
getHandwritingBoundsOffsetRight()
Return the amount of offset applied to the right edge of this view's handwriting bounds, in the unit of pixel.
|
Float |
getHandwritingBoundsOffsetTop()
Return the amount of offset applied to the top edge of this view's handwriting bounds, in the unit of pixel.
|
Int |
getHandwritingDelegateFlags()
Returns flags configuring the handwriting delegation behavior for this delegate editor view, as set by setHandwritingDelegateFlags .
|
Runnable? |
getHandwritingDelegatorCallback()
Returns the callback set by setHandwritingDelegatorCallback which should be called when a stylus MotionEvent occurs within this view's bounds. The callback should only be called from the UI thread.
|
Boolean |
getHasOverlappingRendering()
Returns the value for overlapping rendering that is used internally. This is either the value passed into forceHasOverlappingRendering(boolean) , if called, or the return value of hasOverlappingRendering() , otherwise.
|
Int |
getHeight()
Return the height of your view.
|
Unit |
getHitRect(outRect: Rect!)
Hit rectangle in parent's coordinates
|
Int |
getHorizontalFadingEdgeLength()
Returns the size of the horizontal faded edges used to indicate that more content in this view is visible.
|
Int |
getHorizontalScrollbarHeight()
Returns the height of the horizontal scrollbar.
|
Drawable? |
getHorizontalScrollbarThumbDrawable()
Returns the currently configured Drawable for the thumb of the horizontal scroll bar if it exists, null otherwise.
|
Drawable? |
getHorizontalScrollbarTrackDrawable()
Returns the currently configured Drawable for the track of the horizontal scroll bar if it exists, null otherwise.
|
Int |
getId()
Returns this view's identifier.
|
Int |
getImportantForAccessibility()
Gets the mode for determining whether this View is important for accessibility. A view is important for accessibility if it fires accessibility events and if it is reported to accessibility services that query the screen.
|
Int |
getImportantForAutofill()
Gets the mode for determining whether this view is important for autofill.
See setImportantForAutofill(int) and isImportantForAutofill() for more info about this mode.
|
Int |
getImportantForContentCapture()
Gets the mode for determining whether this view is important for content capture.
See setImportantForContentCapture(int) and isImportantForContentCapture() for more info about this mode.
|
Boolean |
getKeepScreenOn()
Returns whether the screen should remain on, corresponding to the current value of KEEP_SCREEN_ON .
|
KeyEvent.DispatcherState! |
getKeyDispatcherState()
Return the global KeyEvent.DispatcherState for this view's window. Returns null if the view is not currently attached to the window. Normally you will not need to use this directly, but just use the standard high-level event callbacks like onKeyDown(int,android.view.KeyEvent) .
|
Int |
getLabelFor()
Gets the id of a view for which this view serves as a label for accessibility purposes.
|
Int |
getLayerType()
Indicates what type of layer is currently associated with this view. By default a view does not have a layer, and the layer type is LAYER_TYPE_NONE . Refer to the documentation of setLayerType(int,android.graphics.Paint) for more information on the different types of layers.
|
Int |
getLayoutDirection()
Returns the resolved layout direction for this view.
|
ViewGroup.LayoutParams! |
getLayoutParams()
Get the LayoutParams associated with this view. All views should have layout parameters. These supply parameters to the parent of this view specifying how it should be arranged. There are many subclasses of ViewGroup.LayoutParams, and these correspond to the different subclasses of ViewGroup that are responsible for arranging their children. This method may return null if this View is not attached to a parent ViewGroup or setLayoutParams(android.view.ViewGroup.LayoutParams) was not invoked successfully. When a View is attached to a parent ViewGroup, this method must not return null.
|
Int |
getLeft()
Left position of this view relative to its parent.
|
Float |
getLeftFadingEdgeStrength()
Returns the strength, or intensity, of the left faded edge. The strength is a value between 0.0 (no fade) and 1.0 (full fade). The default implementation returns 0.0 or 1.0 but no value in between. Subclasses should override this method to provide a smoother fade transition when scrolling occurs.
|
Int |
getLeftPaddingOffset()
Amount by which to extend the left fading region. Called only when isPaddingOffsetRequired() returns true.
|
Boolean |
getLocalVisibleRect(r: Rect!)
Sets r to the coordinates of the non-clipped area of this view relative to the top left corner of the view.
If the view is clipped on the left or top, the left and top coordinates are offset from 0 by the clipped amount. For example, if the view is off screen 50px on the left and 30px at the top, the left and top coordinates are 50 and 30 respectively.
If the view is clipped on the right or bottom, the right and bottom coordinates are reduced by the clipped amount. For example, if the view is off screen 40px on the right and 20px at the bottom, the right coordinate is the view width - 40, and the bottom coordinate is the view height - 20.
|
Unit |
getLocationInSurface(location: IntArray)
Gets the coordinates of this view in the coordinate space of the Surface that contains the view.
In multiple-screen scenarios, if the surface spans multiple screens, the coordinate space of the surface also spans multiple screens.
After the method returns, the argument array contains the x and y coordinates of the view relative to the view's left and top edges, respectively.
|
Unit |
getLocationInWindow(outLocation: IntArray!)
Gets the coordinates of this view in the coordinate space of the window that contains the view, irrespective of system decorations.
In multi-window mode, the origin of the coordinate space is the top left corner of the window that contains the view. In full screen mode, the origin is the top left corner of the device screen.
In multiple-screen scenarios, if the app spans multiple screens, the coordinate space also spans multiple screens. But if the app is restricted to a single screen, the coordinate space includes only the screen on which the app is running.
After the method returns, the argument array contains the x and y coordinates of the view relative to the view's left and top edges, respectively.
|
Unit |
getLocationOnScreen(outLocation: IntArray!)
Gets the coordinates of this view in the coordinate space of the device screen, irrespective of system decorations and whether the system is in multi-window mode.
In multi-window mode, the coordinate space encompasses the entire device screen, ignoring the bounds of the app window. For example, if the view is in the bottom portion of a horizontal split screen, the top edge of the screen—not the top edge of the window—is the origin from which the y-coordinate is calculated.
In multiple-screen scenarios, the coordinate space can span screens. For example, if the app is spanning both screens of a dual-screen device and the view is located on the right-hand screen, the x-coordinate is calculated from the left edge of the left-hand screen to the left edge of the view. When the app is restricted to a single screen in a multiple-screen environment, the coordinate space includes only the screen on which the app is running.
After the method returns, the argument array contains the x and y coordinates of the view relative to the view's left and top edges, respectively.
|
Matrix! |
getMatrix()
The transform matrix of this view, which is calculated based on the current rotation, scale, and pivot properties.
|
Int |
getMeasuredHeight()
Like getMeasuredHeightAndState() , but only returns the raw height component (that is the result is masked by MEASURED_SIZE_MASK ).
|
Int |
getMeasuredHeightAndState()
Return the full height measurement information for this view as computed by the most recent call to 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 getHeight() to see how high a view is after layout.
|
Int |
getMeasuredState()
Return only the state bits of getMeasuredWidthAndState() and getMeasuredHeightAndState() , 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 .
|
Int |
getMeasuredWidth()
Like getMeasuredWidthAndState() , but only returns the raw width component (that is the result is masked by MEASURED_SIZE_MASK ).
|
Int |
getMeasuredWidthAndState()
Return the full width measurement information for this view as computed by the most recent call to 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 getWidth() to see how wide a view is after layout.
|
Int |
getMinimumHeight()
Returns the minimum height of the view.
|
Int |
getMinimumWidth()
Returns the minimum width of the view.
|
Int |
getNextClusterForwardId()
Gets the id of the root of the next keyboard navigation cluster.
|
Int |
getNextFocusDownId()
Gets the id of the view to use when the next focus is FOCUS_DOWN .
|
Int |
getNextFocusForwardId()
Gets the id of the view to use when the next focus is FOCUS_FORWARD .
|
Int |
getNextFocusLeftId()
Gets the id of the view to use when the next focus is FOCUS_LEFT .
|
Int |
getNextFocusRightId()
Gets the id of the view to use when the next focus is FOCUS_RIGHT .
|
Int |
getNextFocusUpId()
Gets the id of the view to use when the next focus is FOCUS_UP .
|
View.OnFocusChangeListener! |
getOnFocusChangeListener()
Returns the focus-change callback registered for this view.
|
Int |
getOutlineAmbientShadowColor()
|
ViewOutlineProvider! |
getOutlineProvider()
Returns the current ViewOutlineProvider of the view, which generates the Outline that defines the shape of the shadow it casts, and enables outline clipping.
|
Int |
getOutlineSpotShadowColor()
|
Int |
getOverScrollMode()
Returns the over-scroll mode for this view. The result will be one of OVER_SCROLL_ALWAYS , OVER_SCROLL_IF_CONTENT_SCROLLS (allow over-scrolling only if the view content is larger than the container), or OVER_SCROLL_NEVER .
|
ViewOverlay! |
getOverlay()
Returns the overlay for this view, creating it if it does not yet exist. Adding drawables to the overlay will cause them to be displayed whenever the view itself is redrawn. Objects in the overlay should be actively managed: remove them when they should not be displayed anymore. The overlay will always have the same size as its host view.
Note: Overlays do not currently work correctly with SurfaceView or TextureView ; contents in overlays for these types of views may not display correctly.
|
Int |
getPaddingBottom()
Returns the bottom padding of this view. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.
|
Int |
getPaddingEnd()
Returns the end padding of this view depending on its resolved layout direction. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.
|
Int |
getPaddingLeft()
Returns the left padding of this view. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.
|
Int |
getPaddingRight()
Returns the right padding of this view. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.
|
Int |
getPaddingStart()
Returns the start padding of this view depending on its resolved layout direction. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well.
|
Int |
getPaddingTop()
Returns the top padding of this view.
|
ViewParent! |
getParent()
Gets the parent of this view. Note that the parent is a ViewParent and not necessarily a View.
|
ViewParent! |
getParentForAccessibility()
Gets the parent for accessibility purposes. Note that the parent for accessibility is not necessary the immediate parent. It is the first predecessor that is important for accessibility.
|
OutcomeReceiver<GetCredentialResponse!, GetCredentialException!>? |
getPendingCredentialCallback()
Returns the callback that has previously been set up on this view through the setPendingCredentialRequest API. If the return value is null, that means no callback, or request, has been set on the view and no CredentialManager flow will be invoked when this view is focused. Traditioanl autofill flows will still work, and autofillable content will still be returned through the autofill(android.view.autofill.AutofillValue) )} API.
See setPendingCredentialRequest for more info.
|
GetCredentialRequest? |
getPendingCredentialRequest()
Returns the GetCredentialRequest associated with the view. If the return value is null, that means no request has been set on the view and no CredentialManager flow will be invoked when this view is focused. Traditioanl autofill flows will still work, autofilling content if applicable, from the active android.service.autofill.AutofillService on the device.
See setPendingCredentialRequest for more info.
|
Float |
getPivotX()
The x location of the point around which the view is rotated and scaled .
|
Float |
getPivotY()
The y location of the point around which the view is rotated and scaled .
|
PointerIcon! |
getPointerIcon()
Gets the mouse pointer icon for the current view.
|
MutableList<Rect!> |
getPreferKeepClearRects()
|
Array<String!>? |
getReceiveContentMimeTypes()
Returns the MIME types accepted by performReceiveContent for this view, as configured via setOnReceiveContentListener . By default returns null.
Different features (e.g. pasting from the clipboard, inserting stickers from the soft keyboard, etc) may optionally use this metadata to conditionally alter their behavior. For example, a soft keyboard may choose to hide its UI for inserting GIFs for a particular input field if the MIME types returned here for that field don't include "image/gif" or "image/*".
Note: Comparisons of MIME types should be performed using utilities such as ClipDescription#compareMimeTypes rather than simple string equality, in order to correctly handle patterns such as "text/*", "image/*", etc. Note that MIME type matching in the Android framework is case-sensitive, unlike formal RFC MIME types. As a result, you should always write your MIME types with lowercase letters, or use android.content.Intent#normalizeMimeType to ensure that it is converted to lowercase.
|
Float |
getRequestedFrameRate()
Get the current preferred frame rate of the View. The value could be negative when preferred frame rate category is set instead of perferred frame rate. The frame rate category includes REQUESTED_FRAME_RATE_CATEGORY_NO_PREFERENCE, REQUESTED_FRAME_RATE_CATEGORY_LOW, REQUESTED_FRAME_RATE_CATEGORY_NORMAL, and REQUESTED_FRAME_RATE_CATEGORY_HIGH. Note that the frame rate value is valid as long as the View is invalidated.
|
Resources! |
getResources()
Returns the resources associated with this view.
|
Boolean |
getRevealOnFocusHint()
Returns this view's preference for reveal behavior when it gains focus.
When this method returns true for a child view requesting focus, ancestor views responding to a focus change in ViewParent#requestChildFocus(View, View) should make a best effort to make the newly focused child fully visible to the user. When it returns false, ancestor views should preferably not disrupt scroll positioning or other properties affecting visibility to the user as part of the focus change.
|
Int |
getRight()
Right position of this view relative to its parent.
|
Float |
getRightFadingEdgeStrength()
Returns the strength, or intensity, of the right faded edge. The strength is a value between 0.0 (no fade) and 1.0 (full fade). The default implementation returns 0.0 or 1.0 but no value in between. Subclasses should override this method to provide a smoother fade transition when scrolling occurs.
|
Int |
getRightPaddingOffset()
Amount by which to extend the right fading region. Called only when isPaddingOffsetRequired() returns true.
|
AttachedSurfaceControl? |
getRootSurfaceControl()
The AttachedSurfaceControl itself is not a View, it is just the interface to the windowing-system object that contains the entire view hierarchy. For the root View of a given hierarchy see getRootView .
|
View! |
getRootView()
Finds the topmost view in the current view hierarchy.
|
WindowInsets! |
getRootWindowInsets()
Provide original WindowInsets that are dispatched to the view hierarchy. The insets are only available if the view is attached.
|
Float |
getRotation()
The degrees that the view is rotated around the pivot point.
|
Float |
getRotationX()
The degrees that the view is rotated around the horizontal axis through the pivot point.
|
Float |
getRotationY()
The degrees that the view is rotated around the vertical axis through the pivot point.
|
Float |
getScaleX()
The amount that the view is scaled in x around the pivot point, as a proportion of the view's unscaled width. A value of 1, the default, means that no scaling is applied.
By default, this is 1.0f.
|
Float |
getScaleY()
The amount that the view is scaled in y around the pivot point, as a proportion of the view's unscaled height. A value of 1, the default, means that no scaling is applied.
By default, this is 1.0f.
|
Int |
getScrollBarDefaultDelayBeforeFade()
Returns the delay before scrollbars fade.
|
Int |
getScrollBarFadeDuration()
Returns the scrollbar fade duration.
|
Int |
getScrollBarSize()
Returns the scrollbar size.
|
Int |
getScrollBarStyle()
Returns the current scrollbar style.
|
Int |
getScrollCaptureHint()
Returns the current scroll capture hint for this view.
|
Int |
getScrollIndicators()
Returns a bitmask representing the enabled scroll indicators.
For example, if the top and left scroll indicators are enabled and all other indicators are disabled, the return value will be View.SCROLL_INDICATOR_TOP | View.SCROLL_INDICATOR_LEFT .
To check whether the bottom scroll indicator is enabled, use the value of (getScrollIndicators() & View.SCROLL_INDICATOR_BOTTOM) != 0 .
|
Int |
getScrollX()
Return the scrolled left position of this view. This is the left edge of the displayed part of your view. You do not need to draw any pixels farther left, since those are outside of the frame of your view on screen.
|
Int |
getScrollY()
Return the scrolled top position of this view. This is the top edge of the displayed part of your view. You do not need to draw any pixels above it, since those are outside of the frame of your view on screen.
|
Int |
getSolidColor()
Override this if your view is known to always be drawn on top of a solid color background, and needs to draw fading edges. Returning a non-zero color enables the view system to optimize the drawing of the fading edges. If you do return a non-zero color, the alpha should be set to 0xFF.
|
Int |
getSourceLayoutResId()
A View can be inflated from an XML layout. For such Views this method returns the resource ID of the source layout.
|
CharSequence? |
getStateDescription()
Returns the View 's state description.
Note: Do not override this method, as it will have no effect on the state description presented to accessibility services. You must call setStateDescription(java.lang.CharSequence) to modify the state description.
|
StateListAnimator! |
getStateListAnimator()
Returns the current StateListAnimator if exists.
|
Int |
getSuggestedMinimumHeight()
Returns the suggested minimum height that the view should use. This returns the maximum of the view's minimum height and the background's minimum height (android.graphics.drawable.Drawable#getMinimumHeight() ).
When being used in onMeasure(int,int) , the caller should still ensure the returned height is within the requirements of the parent.
|
Int |
getSuggestedMinimumWidth()
Returns the suggested minimum width that the view should use. This returns the maximum of the view's minimum width and the background's minimum width (android.graphics.drawable.Drawable#getMinimumWidth() ).
When being used in onMeasure(int,int) , the caller should still ensure the returned width is within the requirements of the parent.
|
MutableList<Rect!> |
getSystemGestureExclusionRects()
Retrieve the list of areas within this view's post-layout coordinate space where the system should not intercept touch or other pointing device gestures.
Do not modify the returned list.
|
Int |
getSystemUiVisibility()
Returns the last setSystemUiVisibility(int) that this view has requested.
|
Any! |
getTag()
Returns this view's tag.
|
Any! |
getTag(key: Int)
Returns the tag associated with this view and the specified key.
|
Int |
getTextAlignment()
Return the resolved text alignment.
|
Int |
getTextDirection()
Return the resolved text direction.
|
CharSequence? |
getTooltipText()
Returns the view's tooltip text. Note: Do not override this method, as it will have no effect on the text displayed in the tooltip. You must call setTooltipText(java.lang.CharSequence) to modify the tooltip text.
|
Int |
getTop()
Top position of this view relative to its parent.
|
Float |
getTopFadingEdgeStrength()
Returns the strength, or intensity, of the top faded edge. The strength is a value between 0.0 (no fade) and 1.0 (full fade). The default implementation returns 0.0 or 1.0 but no value in between. Subclasses should override this method to provide a smoother fade transition when scrolling occurs.
|
Int |
getTopPaddingOffset()
Amount by which to extend the top fading region. Called only when isPaddingOffsetRequired() returns true.
|
TouchDelegate! |
getTouchDelegate()
Gets the TouchDelegate for this View.
|
ArrayList<View!>! |
getTouchables()
Find and return all touchable views that are descendants of this view, possibly including this view if it is touchable itself.
|
Float |
getTransitionAlpha()
This property is intended only for use by the Fade transition, which animates it to produce a visual translucency that does not side-effect (or get affected by) the real alpha property. This value is composited with the other alpha value (and the AlphaAnimation value, when that is present) to produce a final visual translucency result, which is what is passed into the DisplayList.
|
String! |
getTransitionName()
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.
|
Float |
getTranslationX()
The horizontal location of this view relative to its left position. This position is post-layout, in addition to wherever the object's layout placed it.
|
Float |
getTranslationY()
The vertical location of this view relative to its top position. This position is post-layout, in addition to wherever the object's layout placed it.
|
Float |
getTranslationZ()
The depth location of this view relative to its elevation .
|
Long |
getUniqueDrawingId()
Get the identifier used for this view by the drawing system.
|
Int |
getVerticalFadingEdgeLength()
Returns the size of the vertical faded edges used to indicate that more content in this view is visible.
|
Int |
getVerticalScrollbarPosition()
|
Drawable? |
getVerticalScrollbarThumbDrawable()
Returns the currently configured Drawable for the thumb of the vertical scroll bar if it exists, null otherwise.
|
Drawable? |
getVerticalScrollbarTrackDrawable()
Returns the currently configured Drawable for the track of the vertical scroll bar if it exists, null otherwise.
|
Int |
getVerticalScrollbarWidth()
Returns the width of the vertical scrollbar.
|
ViewTranslationResponse? |
getViewTranslationResponse()
Returns the ViewTranslationResponse associated with this view. The response will be set when the translation is done then onViewTranslationResponse is called. The ViewTranslationCallback can use to get ViewTranslationResponse to display the translated information.
|
ViewTreeObserver! |
getViewTreeObserver()
Returns the ViewTreeObserver for this view's hierarchy. The view tree observer can be used to get notifications when global events, like layout, happen. The returned ViewTreeObserver observer is not guaranteed to remain valid for the lifetime of this View. If the caller of this method keeps a long-lived reference to ViewTreeObserver, it should always check for the return value of ViewTreeObserver#isAlive() .
|
Int |
getVisibility()
Returns the visibility status for this view.
|
Int |
getWidth()
Return the width of your view.
|
Int |
getWindowAttachCount()
|
WindowId! |
getWindowId()
Retrieve the WindowId for the window this view is currently attached to.
|
WindowInsetsController? |
getWindowInsetsController()
Retrieves the single WindowInsetsController of the window this view is attached to.
|
Int |
getWindowSystemUiVisibility()
Returns the current system UI visibility that is currently set for the entire window. This is the combination of the setSystemUiVisibility(int) values supplied by all of the views in the window.
|
IBinder! |
getWindowToken()
Retrieve a unique token identifying the window this view is attached to.
|
Int |
getWindowVisibility()
Returns the current visibility of the window this view is attached to (either GONE , INVISIBLE , or VISIBLE ).
|
Unit |
getWindowVisibleDisplayFrame(outRect: Rect!)
Retrieve the overall visible display size in which the window this view is attached to has been positioned in. This takes into account screen decorations above the window, for both cases where the window itself is being position inside of them or the window is being placed under then and covered insets are used for the window to position its content inside. In effect, this tells you the available area where content can be placed and remain visible to users.
|
Float |
getX()
The visual x position of this view, in pixels. This is equivalent to the translationX property plus the current left property.
|
Float |
getY()
The visual y position of this view, in pixels. This is equivalent to the translationY property plus the current top property.
|
Float |
getZ()
The visual z position of this view, in pixels. This is equivalent to the translationZ property plus the current elevation property.
|
Boolean |
hasExplicitFocusable()
Returns true if this view is focusable or if it contains a reachable View for which hasExplicitFocusable() returns 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-Build.VERSION_CODES#O behavior of hasFocusable() in that only views explicitly set focusable will cause this method to return true. A view set to FOCUSABLE_AUTO that resolves to focusable will not.
|
Boolean |
hasFocus()
Returns true if this view has focus itself, or is the ancestor of the view that has focus.
|
Boolean |
hasFocusable()
Returns true if this view is focusable or if it contains a reachable View for which hasFocusable() returns true . A "reachable hasFocusable()" is a view whose parents do not block descendants focus. Only VISIBLE views are considered focusable.
As of Build.VERSION_CODES#O views that are determined to be focusable through FOCUSABLE_AUTO will also cause this method to return true . Apps that declare a android.content.pm.ApplicationInfo#targetSdkVersion of earlier than Build.VERSION_CODES#O will continue to see this method return false for views not explicitly marked as focusable. Use hasExplicitFocusable() if you require the pre-Build.VERSION_CODES#O behavior.
|
Boolean |
hasNestedScrollingParent()
Returns true if this view has a nested scrolling parent.
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.
|
Boolean |
hasOnClickListeners()
Return whether this view has an attached OnClickListener. Returns true if there is a listener, false if there is none.
|
Boolean |
hasOnLongClickListeners()
Return whether this view has an attached OnLongClickListener. Returns true if there is a listener, false if there is none.
|
Boolean |
hasPointerCapture()
Checks pointer capture status.
|
Boolean |
hasTransientState()
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.
A view with transient state cannot be trivially rebound from an external data source, such as an adapter binding item views in a list. This may be because the view is performing an animation, tracking user selection of content, or similar.
|
Boolean |
hasWindowFocus()
Returns true if this view is in a window that currently has window focus. Note that this is not the same as the view itself having focus.
|
View! |
inflate(context: Context!, resource: Int, root: ViewGroup!)
Inflate a view from an XML resource. This convenience method wraps the LayoutInflater class, which provides a full range of options for view inflation.
|
Unit |
invalidate(dirty: Rect!)
Mark the area defined by dirty as needing to be drawn. If the view is visible, onDraw(android.graphics.Canvas) will be called at some point in the future.
This must be called from a UI thread. To call from a non-UI thread, call postInvalidate() .
WARNING: In API 19 and below, this method may be destructive to dirty .
|
Unit |
invalidate(l: Int, t: Int, r: Int, b: Int)
Mark the area defined by the rect (l,t,r,b) as needing to be drawn. The coordinates of the dirty rect are relative to the view. If the view is visible, onDraw(android.graphics.Canvas) will be called at some point in the future.
This must be called from a UI thread. To call from a non-UI thread, call postInvalidate() .
|
Unit |
invalidate()
Invalidate the whole view. If the view is visible, onDraw(android.graphics.Canvas) will be called at some point in the future.
This must be called from a UI thread. To call from a non-UI thread, call postInvalidate() .
|
Unit |
invalidateOutline()
Called to rebuild this View's Outline from its outline provider
|
Boolean |
isAccessibilityDataSensitive()
Whether this view should restrict accessibility service access only to services that have the android.accessibilityservice.AccessibilityServiceInfo#isAccessibilityTool property set to true.
See default behavior provided by ACCESSIBILITY_DATA_SENSITIVE_AUTO . Otherwise, returns true for ACCESSIBILITY_DATA_SENSITIVE_YES or false for ACCESSIBILITY_DATA_SENSITIVE_NO .
|
Boolean |
isAccessibilityFocused()
Returns whether this View is accessibility focused.
|
Boolean |
isAccessibilityHeading()
Gets whether this view is a heading for accessibility purposes.
|
Boolean |
isActivated()
Indicates the activation state of this view.
|
Boolean |
isAttachedToWindow()
Returns true if this view is currently attached to a window.
|
Boolean |
isAutoHandwritingEnabled()
Return whether the View allows automatic handwriting initiation. Returns true if automatic handwriting initiation is enabled, and vice versa.
|
Boolean |
isClickable()
Indicates whether this view reacts to click events or not.
|
Boolean |
isContentSensitive()
Returns whether this view displays sensitive content, based on the value explicitly set by setContentSensitivity(int) .
|
Boolean |
isContextClickable()
Indicates whether this view reacts to context clicks or not.
|
Boolean |
isCredential()
Gets the mode for determining whether this view is a credential.
See setIsCredential(boolean) .
|
Boolean |
isDirty()
True if this view has changed since the last time being drawn.
|
Boolean |
isDrawingCacheEnabled()
Indicates whether the drawing cache is enabled for this view.
|
Boolean |
isDuplicateParentStateEnabled()
Indicates whether this duplicates its drawable state from its parent.
|
Boolean |
isEnabled()
Returns the enabled status for this view. The interpretation of the enabled state varies by subclass.
|
Boolean |
isFocusable()
Returns whether this View is currently able to take focus.
|
Boolean |
isFocusableInTouchMode()
When a view is focusable, it may not want to take focus when in touch mode. For example, a button would like focus when the user is navigating via a D-pad so that the user can click on it, but once the user starts touching the screen, the button shouldn't take focus
|
Boolean |
isFocused()
Returns true if this view has focus
|
Boolean |
isFocusedByDefault()
Returns whether this View should receive focus when the focus is restored for the view hierarchy containing this view.
Focus gets restored for a view hierarchy when the root of the hierarchy gets added to a window or serves as a target of cluster navigation.
|
Boolean |
isForceDarkAllowed()
See setForceDarkAllowed(boolean)
|
Boolean |
isHandwritingDelegate()
Returns whether this view has been set as a handwriting delegate by setIsHandwritingDelegate .
|
Boolean |
isHapticFeedbackEnabled()
|
Boolean |
isHardwareAccelerated()
Indicates whether this view is attached to a hardware accelerated window or not.
Even if this method returns true, it does not mean that every call to draw(android.graphics.Canvas) will be made with an hardware accelerated android.graphics.Canvas . For instance, if this view is drawn onto an offscreen android.graphics.Bitmap and its window is hardware accelerated, android.graphics.Canvas#isHardwareAccelerated() will likely return false, and this method will return true.
|
Boolean |
isHorizontalFadingEdgeEnabled()
Indicate whether the horizontal edges are faded when the view is scrolled horizontally.
|
Boolean |
isHorizontalScrollBarEnabled()
Indicate whether the horizontal scrollbar should be drawn or not. The scrollbar is not drawn by default.
|
Boolean |
isHovered()
Returns true if the view is currently hovered.
|
Boolean |
isImportantForAccessibility()
Computes whether this view should be exposed for accessibility. In general, views that are interactive or provide information are exposed while views that serve only as containers are hidden.
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() 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:
- Has an accessibility pane title, see
setAccessibilityPaneTitle
- Is an accessibility heading, see
setAccessibilityHeading(boolean) .
|
Boolean |
isImportantForAutofill()
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 false for performance reasons (since the important info is provided by their children), but if its properties have relevant information (for example, a resource id called credentials , it should return true . On the other hand, views representing labels or editable fields should typically return true , but in some cases they could return false (for example, if they're part of a "Captcha" mechanism).
The value returned by this method depends on the value returned by getImportantForAutofill() :
- if it returns
IMPORTANT_FOR_AUTOFILL_YES or IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS , then it returns true
- if it returns
IMPORTANT_FOR_AUTOFILL_NO or IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS , then it returns false
- if it returns
IMPORTANT_FOR_AUTOFILL_AUTO , then it uses some simple heuristics that can return true in some cases (like a container with a resource id), but false in most.
- otherwise, it returns
false .
The behavior of importances depends on Android version:
- For
android.os.Build.VERSION_CODES#TIRAMISU and below:
- When a view is considered important for autofill:
- The view might automatically trigger an autofill request when focused on.
- The contents of the view are included in the
ViewStructure used in an autofill request.
- On the other hand, when a view is considered not important for autofill:
- The view never automatically triggers autofill requests, but it can trigger a manual request through
AutofillManager#requestAutofill(View) .
- The contents of the view are not included in the
ViewStructure used in an autofill request, unless the request has the AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS flag.
- For
android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE and above:
- The system uses importance, along with other view properties and other optimization factors, to determine if a view should trigger autofill on focus.
- The contents of
IMPORTANT_FOR_AUTOFILL_AUTO , IMPORTANT_FOR_AUTOFILL_YES , IMPORTANT_FOR_AUTOFILL_NO , IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS , and IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS views will be included in the ViewStructure used in an autofill request.
|
Boolean |
isImportantForContentCapture()
Hints the Android System whether this view is considered important for content capture, based on the value explicitly set by setImportantForContentCapture(int) and heuristics when it's IMPORTANT_FOR_CONTENT_CAPTURE_AUTO .
See ContentCaptureManager for more info about content capture.
|
Boolean |
isInEditMode()
Indicates whether this View is currently in edit mode. A View is usually in edit mode when displayed within a developer tool. For instance, if this View is being drawn by a visual user interface builder, this method should return true. Subclasses should check the return value of this method to provide different behaviors if their normal behavior might interfere with the host environment. For instance: the class spawns a thread in its constructor, the drawing code relies on device-specific features, etc. This method is usually checked in the drawing code of custom widgets.
|
Boolean |
isInLayout()
Returns whether the view hierarchy is currently undergoing a layout pass. This information is useful to avoid situations such as calling requestLayout() during a layout pass.
|
Boolean |
isInTouchMode()
Returns the touch mode state associated with this view. Attached views return the touch mode state from the associated window's display. Detached views just return the default touch mode value defined in com.android.internal.R.bool.config_defaultInTouchMode . Touch mode is entered once the user begins interacting with the device by touch, and affects various things like whether focus highlight is always visible to the user.
|
Boolean |
isKeyboardNavigationCluster()
Returns whether this View is a root of a keyboard navigation cluster.
|
Boolean |
isLaidOut()
Returns true if this view has been through at least one layout since it was last attached to or detached from a window.
|
Boolean |
isLayoutDirectionResolved()
|
Boolean |
isLayoutRequested()
Indicates whether or not this view's layout will be requested during the next hierarchy layout pass.
|
Boolean |
isLongClickable()
Indicates whether this view reacts to long click events or not.
|
Boolean |
isNestedScrollingEnabled()
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 data about the scroll operation in progress to a compatible and cooperating nested scrolling parent.
|
Boolean |
isPaddingOffsetRequired()
If the View draws content inside its padding and enables fading edges, it needs to support padding offsets. Padding offsets are added to the fading edges to extend the length of the fade so that it covers pixels drawn inside the padding. Subclasses of this class should override this method if they need to draw content inside the padding.
|
Boolean |
isPaddingRelative()
Return if the padding has been set through relative values setPaddingRelative(int,int,int,int) or through
|
Boolean |
isPivotSet()
Returns whether or not a pivot has been set by a call to setPivotX(float) or setPivotY(float) . If no pivot has been set then the pivot will be the center of the view.
|
Boolean |
isPreferKeepClear()
Retrieve the preference for this view to be kept clear. This is set either by setPreferKeepClear or via the attribute android.R.styleable#View_preferKeepClear.
If this is true , the system will ignore the Rects set by setPreferKeepClearRects and try to keep the whole view clear.
|
Boolean |
isPressed()
Indicates whether the view is currently in pressed state. Unless setPressed(boolean) is explicitly called, only clickable views can enter the pressed state.
|
Boolean |
isSaveEnabled()
Indicates whether this view will save its state (that is, whether its onSaveInstanceState method will be called).
|
Boolean |
isSaveFromParentEnabled()
Indicates whether the entire hierarchy under this view will save its state when a state saving traversal occurs from its parent. The default is true; if false, these views will not be saved unless saveHierarchyState(android.util.SparseArray) is called directly on this view.
|
Boolean |
isScreenReaderFocusable()
Returns whether the view should be treated as a focusable unit by screen reader accessibility tools.
Note: Use androidx.core.view.ViewCompat#setScreenReaderFocusable(View, boolean) for backwards-compatibility.
|
Boolean |
isScrollContainer()
Indicates whether this view is one of the set of scrollable containers in its window.
|
Boolean |
isScrollbarFadingEnabled()
Returns true if scrollbars will fade when this view is not scrolling
|
Boolean |
isSelected()
Indicates the selection state of this view.
|
Boolean |
isShowingLayoutBounds()
Returns true when the View is attached and the system developer setting to show the layout bounds is enabled or false otherwise.
|
Boolean |
isShown()
Returns the visibility of this view and all of its ancestors
|
Boolean |
isSoundEffectsEnabled()
|
Boolean |
isTemporarilyDetached()
Tells whether the View is in the state between onStartTemporaryDetach() and onFinishTemporaryDetach() .
This method always returns true when called directly or indirectly from onStartTemporaryDetach() . The return value when called directly or indirectly from onFinishTemporaryDetach() , however, depends on the OS version.
|
Boolean |
isTextAlignmentResolved()
|
Boolean |
isTextDirectionResolved()
|
Boolean |
isVerticalFadingEdgeEnabled()
Indicate whether the vertical edges are faded when the view is scrolled horizontally.
|
Boolean |
isVerticalScrollBarEnabled()
Indicate whether the vertical scrollbar should be drawn or not. The scrollbar is not drawn by default.
|
Boolean |
isVisibleToUserForAutofill(virtualId: Int)
Computes whether this virtual autofill view is visible to the user.
Note: By default it returns true , but views providing a virtual hierarchy view must override it.
|
View! |
keyboardNavigationClusterSearch(currentCluster: View!, direction: Int)
Find the nearest keyboard navigation cluster in the specified direction. This does not actually give focus to that cluster.
|
Unit |
layout(l: Int, t: Int, r: Int, b: Int)
Assign a size and position to a view and all of its descendants
This is the second phase of the layout mechanism. (The first is measuring). In this phase, each parent calls layout on all of its children to position them. This is typically done using the child measurements that were stored in the measure pass().
Derived classes should not override this method. Derived classes with children should override onLayout. In that method, they should call layout on each of their children.
|
Unit |
measure(widthMeasureSpec: Int, heightMeasureSpec: Int)
This is called to find out how big a view should be. The parent supplies constraint information in the width and height parameters.
The actual measurement work of a view is performed in onMeasure(int,int) , called by this method. Therefore, only onMeasure(int,int) can and must be overridden by subclasses.
|
IntArray! |
mergeDrawableStates(baseState: IntArray!, additionalState: IntArray!)
Merge your own state values in additionalState into the base state values baseState that were returned by onCreateDrawableState(int) .
|
Unit |
offsetLeftAndRight(offset: Int)
Offset this view's horizontal location by the specified amount of pixels.
|
Unit |
offsetTopAndBottom(offset: Int)
Offset this view's vertical location by the specified number of pixels.
|
Unit |
onAnimationEnd()
Invoked by a parent ViewGroup to notify the end of the animation currently associated with this view. If you override this method, always call super.onAnimationEnd(); If you override this method you must call through to the superclass implementation.
|
Unit |
onAnimationStart()
Invoked by a parent ViewGroup to notify the start of the animation currently associated with this view. If you override this method, always call super.onAnimationStart(); If you override this method you must call through to the superclass implementation.
|
WindowInsets! |
onApplyWindowInsets(insets: WindowInsets!)
Called when the view should apply WindowInsets according to its internal policy.
This method should be overridden by views that wish to apply a policy different from or in addition to the default behavior. Clients that wish to force a view subtree to apply insets should call dispatchApplyWindowInsets(android.view.WindowInsets) .
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.
Implementations of this method should either return the insets parameter unchanged or a new WindowInsets cloned from the supplied insets with any insets consumed that this view applied itself. This allows new inset types added in future platform versions to pass through existing implementations unchanged without being erroneously consumed.
By default if a view's fitsSystemWindows property is set then the view will consume the system window insets and apply them as padding for the view.
|
Unit |
onCancelPendingInputEvents()
Called as the result of a call to cancelPendingInputEvents() on this view or a parent view.
This method is responsible for removing any pending high-level input events that were posted to the event queue to run later. Custom view classes that post their own deferred high-level events via post(java.lang.Runnable) , postDelayed(java.lang.Runnable,long) or android.os.Handler should override this method, call super.onCancelPendingInputEvents() and remove those callbacks as appropriate.
|
Boolean |
onCapturedPointerEvent(event: MotionEvent!)
Implement this method to handle captured pointer events
|
Boolean |
onCheckIsTextEditor()
Check whether the called view is a text editor, in which case it would make sense to automatically display a soft input window for it. Subclasses should override this if they implement onCreateInputConnection(android.view.inputmethod.EditorInfo) to return true if a call on that method would return a non-null InputConnection, and they are really a first-class editor that the user would normally start typing on when the go into a window containing your view.
The default implementation always returns false. This does not mean that its onCreateInputConnection(android.view.inputmethod.EditorInfo) will not be called or the user can not otherwise perform edits on your view; it is just a hint to the system that this is not the primary purpose of this view.
|
Unit |
onConfigurationChanged(newConfig: Configuration!)
Called when the current configuration of the resources being used by the application have changed. You can use this to decide when to reload resources that can changed based on orientation and other configuration characteristics. You only need to use this if you are not relying on the normal android.app.Activity mechanism of recreating the activity instance upon a configuration change.
|
Unit |
onCreateContextMenu(menu: ContextMenu!)
Views should implement this if the view itself is going to add items to the context menu.
|
InputConnection! |
onCreateInputConnection(outAttrs: EditorInfo!)
Create a new InputConnection for an InputMethod to interact with the view. The default implementation returns null, since it doesn't support input methods. You can override this to implement such support. This is only needed for views that take focus and text input.
When implementing this, you probably also want to implement onCheckIsTextEditor() to indicate you will return a non-null InputConnection.
Also, take good care to fill in the android.view.inputmethod.EditorInfo object correctly and in its entirety, so that the connected IME can rely on its values. For example, android.view.inputmethod.EditorInfo#initialSelStart and android.view.inputmethod.EditorInfo#initialSelEnd members must be filled in with the correct cursor position for IMEs to work correctly with your application.
|
Unit |
onCreateViewTranslationRequest(supportedFormats: IntArray, requestsCollector: Consumer<ViewTranslationRequest!>)
Collects a ViewTranslationRequest which represents the content to be translated in the view.
The default implementation does nothing.
|
Unit |
onCreateVirtualViewTranslationRequests(virtualIds: LongArray, supportedFormats: IntArray, requestsCollector: Consumer<ViewTranslationRequest!>)
Collects ViewTranslationRequest s which represents the content to be translated for the virtual views in the host view. This is called if this view returned a virtual view structure from onProvideContentCaptureStructure and the system determined that those virtual views were relevant for translation.
The default implementation does nothing.
|
Unit |
onDisplayHint(hint: Int)
Gives this view a hint about whether is displayed or not. For instance, when a View moves out of the screen, it might receives a display hint indicating the view is not displayed. Applications should not rely on this hint as there is no guarantee that they will receive one.
|
Boolean |
onDragEvent(event: DragEvent!)
Handles drag events sent by the system following a call to startDragAndDrop() .
The system calls this method and passes a DragEvent object in response to drag and drop events. This method can then call DragEvent#getAction() to determine the state of the drag and drop operation.
The default implementation returns false unless an OnReceiveContentListener has been set for this view (see setOnReceiveContentListener ), in which case the default implementation does the following:
|
Unit |
onDrawForeground(canvas: Canvas)
Draw any foreground content for this view.
Foreground content may consist of scroll bars, a foreground drawable or other view-specific decorations. The foreground is drawn on top of the primary view content.
|
Unit |
onDrawScrollBars(canvas: Canvas)
Request the drawing of the horizontal and the vertical scrollbar. The scrollbars are painted only if they have been awakened first.
|
Boolean |
onFilterTouchEventForSecurity(event: MotionEvent!)
Filter the touch event to apply security policies.
|
Unit |
onFinishInflate()
Finalize inflating a view from XML. This is called as the last phase of inflation, after all child views have been added.
Even if the subclass overrides onFinishInflate, they should always be sure to call the super method, so that we get called. If you override this method you must call through to the superclass implementation.
|
Unit |
onFinishTemporaryDetach()
Called after onStartTemporaryDetach when the container is done changing the view.
|
Unit |
onFocusChanged(gainFocus: Boolean, direction: Int, previouslyFocusedRect: Rect?)
Called by the view system when the focus state of this view changes. When the focus change event is caused by directional navigation, direction and previouslyFocusedRect provide insight into where the focus is coming from. When overriding, be sure to call up through to the super class so that the standard focus handling will occur. If you override this method you must call through to the superclass implementation.
|
Boolean |
onGenericMotionEvent(event: MotionEvent!)
Implement this method to handle generic motion events.
Generic motion events describe joystick movements, hover events from mouse or stylus devices, trackpad touches, scroll wheel movements and other motion events not handled by onTouchEvent(android.view.MotionEvent) or onTrackballEvent(android.view.MotionEvent) . The source of the motion event specifies the class of input that was received. Implementations of this method must examine the bits in the source before processing the event. The following code example shows how this is done.
Generic motion events with source class InputDevice#SOURCE_CLASS_POINTER are delivered to the view under the pointer. All other generic motion events are delivered to the focused view.
public boolean onGenericMotionEvent(MotionEvent event) {
if (event.isFromSource(InputDevice.SOURCE_CLASS_JOYSTICK)) {
if (event.getAction() == MotionEvent.ACTION_MOVE) {
// process the joystick movement...
return true;
}
}
if (event.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) {
switch (event.getAction()) {
case MotionEvent.ACTION_HOVER_MOVE:
// process the hover movement...
return true;
case MotionEvent.ACTION_SCROLL:
// process the scroll wheel movement...
return true;
}
}
return super.onGenericMotionEvent(event);
}
|
Unit |
onHoverChanged(hovered: Boolean)
Implement this method to handle hover state changes.
This method is called whenever the hover state changes as a result of a call to setHovered .
|
Boolean |
onHoverEvent(event: MotionEvent!)
Implement this method to handle hover events.
This method is called whenever a pointer is hovering into, over, or out of the bounds of a view and the view is not currently being touched. Hover events are represented as pointer events with action MotionEvent#ACTION_HOVER_ENTER , MotionEvent#ACTION_HOVER_MOVE , or MotionEvent#ACTION_HOVER_EXIT .
- The view receives a hover event with action
MotionEvent#ACTION_HOVER_ENTER when the pointer enters the bounds of the view.
- The view receives a hover event with action
MotionEvent#ACTION_HOVER_MOVE when the pointer has already entered the bounds of the view and has moved.
- The view receives a hover event with action
MotionEvent#ACTION_HOVER_EXIT when the pointer has exited the bounds of the view or when the pointer is about to go down due to a button click, tap, or similar user action that causes the view to be touched.
The view should implement this method to return true to indicate that it is handling the hover event, such as by changing its drawable state.
The default implementation calls setHovered to update the hovered state of the view when a hover enter or hover exit event is received, if the view is enabled and is clickable. The default implementation also sends hover accessibility events.
|
Unit |
onInitializeAccessibilityEvent(event: AccessibilityEvent!)
Initializes an 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 AccessibilityDelegate has been specified via calling setAccessibilityDelegate(android.view.View.AccessibilityDelegate) its AccessibilityDelegate#onInitializeAccessibilityEvent(View, AccessibilityEvent) is responsible for handling this call.
Note: Always call the super implementation before adding information to the event, in case the default implementation has basic information to add.
If you override this method you must call through to the superclass implementation.
|
Unit |
onInitializeAccessibilityNodeInfo(info: AccessibilityNodeInfo!)
Initializes an AccessibilityNodeInfo with information about this view. The base implementation sets:
AccessibilityNodeInfo#setParent(View) ,
AccessibilityNodeInfo#setBoundsInParent(Rect) ,
AccessibilityNodeInfo#setBoundsInScreen(Rect) ,
AccessibilityNodeInfo#setPackageName(CharSequence) ,
AccessibilityNodeInfo#setClassName(CharSequence) ,
AccessibilityNodeInfo#setContentDescription(CharSequence) ,
AccessibilityNodeInfo#setEnabled(boolean) ,
AccessibilityNodeInfo#setClickable(boolean) ,
AccessibilityNodeInfo#setFocusable(boolean) ,
AccessibilityNodeInfo#setFocused(boolean) ,
AccessibilityNodeInfo#setLongClickable(boolean) ,
AccessibilityNodeInfo#setSelected(boolean) ,
AccessibilityNodeInfo#setContextClickable(boolean)
Subclasses should override this method, call the super implementation, and set additional attributes.
If an AccessibilityDelegate has been specified via calling setAccessibilityDelegate(android.view.View.AccessibilityDelegate) its AccessibilityDelegate#onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfo) is responsible for handling this call.
If you override this method you must call through to the superclass implementation.
|
Boolean |
onKeyDown(keyCode: Int, event: KeyEvent!)
Default implementation of KeyEvent.Callback.onKeyDown() : perform press of the view when KeyEvent#KEYCODE_DPAD_CENTER or KeyEvent#KEYCODE_ENTER is released, if the view is enabled and clickable.
Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.
|
Boolean |
onKeyLongPress(keyCode: Int, event: KeyEvent!)
Default implementation of KeyEvent.Callback.onKeyLongPress() : always returns false (doesn't handle the event).
Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.
|
Boolean |
onKeyMultiple(keyCode: Int, repeatCount: Int, event: KeyEvent!)
Default implementation of KeyEvent.Callback.onKeyMultiple() : always returns false (doesn't handle the event).
Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.
|
Boolean |
onKeyPreIme(keyCode: Int, event: KeyEvent!)
Handle a key event before it is processed by any input method associated with the view hierarchy. This can be used to intercept key events in special situations before the IME consumes them; a typical example would be handling the BACK key to update the application's UI instead of allowing the IME to see it and close itself. Due to a bug, this function is not called for BACK key events on Android T and U, when the IME is shown.
|
Boolean |
onKeyShortcut(keyCode: Int, event: KeyEvent!)
Called on the focused view when a key shortcut event is not handled. Override this method to implement local key shortcuts for the View. Key shortcuts can also be implemented by setting the shortcut property of menu items.
|
Boolean |
onKeyUp(keyCode: Int, event: KeyEvent!)
Default implementation of KeyEvent.Callback.onKeyUp() : perform clicking of the view when KeyEvent#KEYCODE_DPAD_CENTER , KeyEvent#KEYCODE_ENTER or KeyEvent#KEYCODE_SPACE is released.
Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.
|
Unit |
onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int)
Called from layout when this view should assign a size and position to each of its children. Derived classes with children should override this method and call layout on each of their children.
|
Unit |
onOverScrolled(scrollX: Int, scrollY: Int, clampedX: Boolean, clampedY: Boolean)
Called by overScrollBy(int,int,int,int,int,int,int,int,boolean) to respond to the results of an over-scroll operation.
|
Unit |
onPointerCaptureChange(hasCapture: Boolean)
Called when the window has just acquired or lost pointer capture. If you override this method you must call through to the superclass implementation.
|
Unit |
onPopulateAccessibilityEvent(event: AccessibilityEvent!)
Called from dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent) giving a chance to this View to populate the accessibility event with its text content.
Note: This method should only be used with event.setText(). Avoid mutating other event state in this method. Instead, follow the practices described in dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent) . In general, put UI metadata in the node for services to easily query, than in transient events.
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 AccessibilityDelegate has been specified via calling setAccessibilityDelegate(android.view.View.AccessibilityDelegate) its AccessibilityDelegate#onPopulateAccessibilityEvent(View, AccessibilityEvent) is responsible for handling this call.
Note: Always call the super implementation before adding information to the event, in case the default implementation has basic information to add.
If you override this method you must call through to the superclass implementation.
|
Unit |
onProvideAutofillStructure(structure: ViewStructure!, flags: Int)
Populates a ViewStructure to fullfil an autofill request.
The structure should contain at least the following properties:
It's also recommended to set the following properties - the more properties the structure has, the higher the chances of an android.service.autofill.AutofillService properly using the structure:
- Autofill hints (
ViewStructure#setAutofillHints(String[]) ).
- Autofill options (
ViewStructure#setAutofillOptions(CharSequence[]) ) when the view can only be filled with predefined values (typically used when the autofill type is AUTOFILL_TYPE_LIST ).
- Resource id (
ViewStructure#setId(int, String, String, String) ).
- Class name (
ViewStructure#setClassName(String) ).
- Content description (
ViewStructure#setContentDescription(CharSequence) ).
- Visual properties such as visibility (
ViewStructure#setVisibility(int) ), dimensions (ViewStructure#setDimens(int, int, int, int, int, int) ), and opacity (ViewStructure#setOpaque(boolean) ).
- For views representing text fields, text properties such as the text itself (
ViewStructure#setText(CharSequence) ), text hints (ViewStructure#setHint(CharSequence) , input type (ViewStructure#setInputType(int) ),
- For views representing HTML nodes, its web domain (
ViewStructure#setWebDomain(String) ) and HTML properties ((ViewStructure#setHtmlInfo(android.view.ViewStructure.HtmlInfo) ).
The default implementation of this method already sets most of these properties based on related View methods (for example, the autofill id is set using getAutofillId() , the autofill type set using getAutofillType() , etc.), and views in the standard Android widgets library also override it to set their relevant properties (for example, android.widget.TextView already sets the text properties), so it's recommended to only override this method (and call super.onProvideAutofillStructure() ) when:
Note: The left and top values set in ViewStructure#setDimens(int, int, int, int, int, int) must be relative to the next ViewGroup#isImportantForAutofill() predecessor view included in the structure.
Views support the Autofill Framework mainly by:
- Providing the metadata defining what the view means and how it can be autofilled.
- Notifying the Android System when the view value changed by calling
AutofillManager#notifyValueChanged(View) .
- Implementing the methods that autofill the view.
This method is responsible for the former; autofill(android.view.autofill.AutofillValue) is responsible for the latter.
|
Unit |
onProvideAutofillVirtualStructure(structure: ViewStructure!, flags: Int)
Populates a ViewStructure containing virtual children to fullfil an autofill request.
This method should be used when the view manages a virtual structure under this view. For example, a view that draws input fields using draw(android.graphics.Canvas) .
When implementing this method, subclasses must follow the rules below:
- Add virtual children by calling the
ViewStructure#newChild(int) or ViewStructure#asyncNewChild(int) methods, where the id is an unique id identifying the children in the virtual structure.
- The children hierarchy can have multiple levels if necessary, but ideally it should exclude intermediate levels that are irrelevant for autofill; that would improve the autofill performance.
- Also implement
autofill(android.util.SparseArray) to autofill the virtual children.
- Set the autofill properties of the child structure as defined by
onProvideAutofillStructure(android.view.ViewStructure,int) , using ViewStructure#setAutofillId(AutofillId, int) to set its autofill id.
- Call
android.view.autofill.AutofillManager#notifyViewEntered(View, int, Rect) and/or android.view.autofill.AutofillManager#notifyViewExited(View, int) when the focused virtual child changed.
- Override
isVisibleToUserForAutofill(int) to allow the platform to query whether a given virtual view is visible to the user in order to support triggering save when all views of interest go away.
- Call
android.view.autofill.AutofillManager#notifyValueChanged(View, int, AutofillValue) when the value of a virtual child changed.
- Call
android.view.autofill.AutofillManager#notifyViewVisibilityChanged(View, int, boolean) when the visibility of a virtual child changed.
- Call
android.view.autofill.AutofillManager#notifyViewClicked(View, int) when a virtual child is clicked.
- Call
AutofillManager#commit() when the autofill context of the view structure changed and the current context should be committed (for example, when the user tapped a SUBMIT button in an HTML page).
- Call
AutofillManager#cancel() when the autofill context of the view structure changed and the current context should be canceled (for example, when the user tapped a CANCEL button in an HTML page).
- Provide ways for users to manually request autofill by calling
AutofillManager#requestAutofill(View, int, Rect) .
- The
left and top values set in ViewStructure#setDimens(int, int, int, int, int, int) must be relative to the next ViewGroup#isImportantForAutofill() predecessor view included in the structure.
Views with virtual children support the Autofill Framework mainly by:
- Providing the metadata defining what the virtual children mean and how they can be autofilled.
- Implementing the methods that autofill the virtual children.
This method is responsible for the former; autofill(android.util.SparseArray) is responsible for the latter.
|
Unit |
onProvideContentCaptureStructure(structure: ViewStructure, flags: Int)
Populates a ViewStructure for content capture.
This method is called after a view that is eligible for content capture (for example, if it isImportantForContentCapture() , an intelligence service is enabled for the user, and the activity rendering the view is enabled for content capture) is laid out and is visible. The populated structure is then passed to the service through ContentCaptureSession#notifyViewAppeared(ViewStructure) .
The default implementation of this method sets the most relevant properties based on related View methods, and views in the standard Android widgets library also override it to set their relevant properties. Therefore, if overriding this method, it is recommended to call super.onProvideContentCaptureStructure() .
Note: views that manage a virtual structure under this view must populate just the node representing this view and return right away, then asynchronously report (not necessarily in the UI thread) when the children nodes appear, disappear or have their text changed by calling ContentCaptureSession#notifyViewAppeared(ViewStructure) , ContentCaptureSession#notifyViewDisappeared(AutofillId) , and ContentCaptureSession#notifyViewTextChanged(AutofillId, CharSequence) respectively. The structure for a child must be created using ContentCaptureSession#newVirtualViewStructure(AutofillId, long) , and the autofillId for a child can be obtained either through childStructure.getAutofillId() or ContentCaptureSession#newAutofillId(AutofillId, long) .
When the virtual view hierarchy represents a web page, you should also:
Note: the following methods of the structure will be ignored:
|
Unit |
onProvideStructure(structure: ViewStructure!)
Called when assist structure is being retrieved from a view as part of Activity.onProvideAssistData .
|
Unit |
onProvideVirtualStructure(structure: ViewStructure!)
Called when assist structure is being retrieved from a view as part of Activity.onProvideAssistData to generate additional virtual structure under this view. The default implementation uses getAccessibilityNodeProvider() to try to generate this from the view's virtual accessibility nodes, if any. You can override this for a more optimal implementation providing this data.
|
ContentInfo? |
onReceiveContent(payload: ContentInfo)
Implements the default behavior for receiving content for this type of view. The default view implementation is a no-op (returns the passed-in content without acting on it).
Widgets should override this method to define their default behavior for receiving content. Apps should set a listener to provide app-specific handling for receiving content.
See setOnReceiveContentListener and performReceiveContent for more info.
|
PointerIcon! |
onResolvePointerIcon(event: MotionEvent!, pointerIndex: Int)
Resolve the pointer icon that should be used for specified pointer in the motion event. The default implementation will resolve the pointer icon to one set using setPointerIcon(android.view.PointerIcon) for mouse devices. Subclasses may override this to customize the icon for the given pointer. For example, the pointer icon for a stylus pointer can be resolved in the following way:
@Override
public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) {
final int toolType = event.getToolType(pointerIndex);
if (!event.isFromSource(InputDevice.SOURCE_MOUSE)
&& event.isFromSource(InputDevice.SOURCE_STYLUS)
&& (toolType == MotionEvent.TOOL_TYPE_STYLUS
|| toolType == MotionEvent.TOOL_TYPE_ERASER)) {
// Show this pointer icon only if this pointer is a stylus.
return PointerIcon.getSystemIcon(mContext, PointerIcon.TYPE_WAIT);
}
// Use the default logic for determining the pointer icon for other non-stylus pointers,
// like for the mouse cursor.
return super.onResolvePointerIcon(event, pointerIndex);
}
|
Unit |
onRestoreInstanceState(state: Parcelable!)
Hook allowing a view to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState . This function will never be called with a null state. If you override this method you must call through to the superclass implementation.
|
Parcelable? |
onSaveInstanceState()
Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state. This state should only contain information that is not persistent or can not be reconstructed later. For example, you will never store your current position on screen because that will be computed again when a new instance of the view is placed in its view hierarchy.
Some examples of things you may store here: the current cursor position in a text view (but usually not the text itself since that is stored in a content provider or other persistent storage), the currently selected item in a list view. If you override this method you must call through to the superclass implementation.
|
Unit |
onScreenStateChanged(screenState: Int)
This method is called whenever the state of the screen this view is attached to changes. A state change will usually occurs when the screen turns on or off (whether it happens automatically or the user does it manually.)
|
Unit |
onScrollCaptureSearch(localVisibleRect: Rect, windowOffset: Point, targets: Consumer<ScrollCaptureTarget!>)
Called when scroll capture is requested, to search for appropriate content to scroll. If applicable, this view adds itself to the provided list for consideration, subject to the flags set by setScrollCaptureHint .
|
Unit |
onScrollChanged(l: Int, t: Int, oldl: Int, oldt: Int)
This is called in response to an internal scroll in this view (i.e., the view scrolled its own contents). This is typically as a result of scrollBy(int,int) or scrollTo(int,int) having been called.
|
Boolean |
onSetAlpha(alpha: Int)
Invoked if there is a Transform that involves alpha. Subclass that can draw themselves with the specified alpha should return true, and then respect that alpha when their onDraw() is called. If this returns false then the view may be redirected to draw into an offscreen buffer to fulfill the request, which will look fine, but may be slower than if the subclass handles it internally. The default implementation returns false.
|
Unit |
onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int)
This is called during layout when the size of this view has changed. If you were just added to the view hierarchy, you're called with the old values of 0.
|
Unit |
onStartTemporaryDetach()
This is called when a container is going to temporarily detach a child, with ViewGroup.detachViewFromParent . It will either be followed by onFinishTemporaryDetach() or onDetachedFromWindow() when the container is done.
|
Boolean |
onTouchEvent(event: MotionEvent!)
Implement this method to handle touch screen motion events.
If this method is used to detect click actions, it is recommended that the actions be performed by implementing and calling performClick() . This will ensure consistent system behavior, including:
- obeying click sound preferences
- dispatching OnClickListener calls
- handling
ACTION_CLICK when accessibility features are enabled
|
Boolean |
onTrackballEvent(event: MotionEvent!)
Implement this method to handle trackball motion events.
The relative movement of the trackball since the last event can be retrieve with android.view.MotionEvent#getX and android.view.MotionEvent#getY. These are normalized so that a movement of 1 corresponds to the user pressing one DPAD key (so they will often be fractional values, representing the more fine-grained movement information available from a trackball).
|
Unit |
onViewTranslationResponse(response: ViewTranslationResponse)
Called when the content from View#onCreateViewTranslationRequest had been translated by the TranslationService. The ViewTranslationResponse should be saved here so that the ViewTranslationResponse can be used to display the translation when the system calls ViewTranslationCallback#onShowTranslation .
The default implementation will set the ViewTranslationResponse that can be get from View#getViewTranslationResponse .
|
Unit |
onVirtualViewTranslationResponses(response: LongSparseArray<ViewTranslationResponse!>)
Called when the content from View#onCreateVirtualViewTranslationRequests had been translated by the TranslationService.
The default implementation does nothing.
|
Unit |
onVisibilityChanged(changedView: View, visibility: Int)
Called when the visibility of the view or an ancestor of the view has changed.
|
Unit |
onWindowFocusChanged(hasWindowFocus: Boolean)
Called when the window containing this view gains or loses focus. Note that this is separate from view focus: to receive key events, both your view and its window must have focus. If a window is displayed on top of yours that takes input focus, then your own window will lose focus but the view focus will remain unchanged.
|
Unit |
onWindowSystemUiVisibilityChanged(visible: Int)
Override to find out when the window's requested system UI visibility has changed, that is the value returned by getWindowSystemUiVisibility() . This is different from the callbacks received through setOnSystemUiVisibilityChangeListener(android.view.View.OnSystemUiVisibilityChangeListener) in that this is only telling you about the local request of the window, not the actual values applied by the system.
|
Unit |
onWindowVisibilityChanged(visibility: Int)
Called when the window containing has change its visibility (between GONE , INVISIBLE , and VISIBLE ). Note that this tells you whether or not your window is being made visible to the window manager; this does not tell you whether or not your window is obscured by other windows on the screen, even if it is itself visible.
|
Boolean |
overScrollBy(deltaX: Int, deltaY: Int, scrollX: Int, scrollY: Int, scrollRangeX: Int, scrollRangeY: Int, maxOverScrollX: Int, maxOverScrollY: Int, isTouchEvent: Boolean)
Scroll the view with standard behavior for scrolling beyond the normal content boundaries. Views that call this method should override onOverScrolled(int,int,boolean,boolean) to respond to the results of an over-scroll operation. Views can use this method to handle any touch or fling-based scrolling.
|
Boolean |
performAccessibilityAction(action: Int, arguments: Bundle?)
Performs the specified accessibility action on the view. For possible accessibility actions look at AccessibilityNodeInfo .
If an AccessibilityDelegate has been specified via calling setAccessibilityDelegate(android.view.View.AccessibilityDelegate) its AccessibilityDelegate#performAccessibilityAction(View, int, Bundle) is responsible for handling this call.
The default implementation will delegate AccessibilityNodeInfo#ACTION_SCROLL_BACKWARD and AccessibilityNodeInfo#ACTION_SCROLL_FORWARD to nested scrolling parents if nested scrolling is enabled on this view.
Note: Avoid setting accessibility focus with AccessibilityNodeInfo#ACTION_ACCESSIBILITY_FOCUS . This is intended to be controlled by screen readers. Apps changing focus can confuse screen readers, so the resulting behavior can vary by device and screen reader version.
|
Boolean |
performClick()
Call this view's OnClickListener, if it is defined. Performs all normal actions associated with clicking: reporting accessibility event, playing a sound, etc.
|
Boolean |
performContextClick(x: Float, y: Float)
Call this view's OnContextClickListener, if it is defined.
|
Boolean |
performContextClick()
Call this view's OnContextClickListener, if it is defined.
|
Boolean |
performHapticFeedback(feedbackConstant: Int)
BZZZTT!!1!
Provide haptic feedback to the user for this view.
The framework will provide haptic feedback for some built in actions, such as long presses, but you may wish to provide feedback for your own widget.
The feedback will only be performed if isHapticFeedbackEnabled() is true.
|
Boolean |
performHapticFeedback(feedbackConstant: Int, flags: Int)
BZZZTT!!1!
Like performHapticFeedback(int) , with additional options.
|
Boolean |
performLongClick()
Calls this view's OnLongClickListener, if it is defined. Invokes the context menu if the OnLongClickListener did not consume the event.
|
Boolean |
performLongClick(x: Float, y: Float)
Calls this view's OnLongClickListener, if it is defined. Invokes the context menu if the OnLongClickListener did not consume the event, anchoring it to an (x,y) coordinate.
|
ContentInfo? |
performReceiveContent(payload: ContentInfo)
Receives the given content. If no listener is set, invokes onReceiveContent . If a listener is set , invokes the listener instead; if the listener returns a non-null result, invokes onReceiveContent to handle it.
|
Unit |
playSoundEffect(soundConstant: Int)
Play a sound effect for this view.
The framework will play sound effects for some built in actions, such as clicking, but you may wish to play these effects in your widget, for instance, for internal navigation.
The sound effect will only be played if sound effects are enabled by the user, and isSoundEffectsEnabled() is true.
|
Boolean |
post(action: Runnable!)
Causes the Runnable to be added to the message queue. The runnable will be run on the user interface thread.
|
Boolean |
postDelayed(action: Runnable!, delayMillis: Long)
Causes the Runnable to be added to the message queue, to be run after the specified amount of time elapses. The runnable will be run on the user interface thread.
|
Unit |
postInvalidate()
Cause an invalidate to happen on a subsequent cycle through the event loop. Use this to invalidate the View from a non-UI thread.
This method can be invoked from outside of the UI thread only when this View is attached to a window.
|
Unit |
postInvalidate(left: Int, top: Int, right: Int, bottom: Int)
Cause an invalidate of the specified area to happen on a subsequent cycle through the event loop. Use this to invalidate the View from a non-UI thread.
This method can be invoked from outside of the UI thread only when this View is attached to a window.
|
Unit |
postInvalidateDelayed(delayMilliseconds: Long)
Cause an invalidate to happen on a subsequent cycle through the event loop. Waits for the specified amount of time.
This method can be invoked from outside of the UI thread only when this View is attached to a window.
|
Unit |
postInvalidateDelayed(delayMilliseconds: Long, left: Int, top: Int, right: Int, bottom: Int)
Cause an invalidate of the specified area to happen on a subsequent cycle through the event loop. Waits for the specified amount of time.
This method can be invoked from outside of the UI thread only when this View is attached to a window.
|
Unit |
postInvalidateOnAnimation()
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.
|
Unit |
postInvalidateOnAnimation(left: Int, top: Int, right: Int, bottom: Int)
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.
|
Unit |
postOnAnimation(action: Runnable!)
Causes the Runnable to execute on the next animation time step. The runnable will be run on the user interface thread.
|
Unit |
postOnAnimationDelayed(action: Runnable!, delayMillis: Long)
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.
|
Unit |
refreshDrawableState()
Call this to force a view to update its drawable state. This will cause drawableStateChanged to be called on this view. Views that are interested in the new state should call getDrawableState.
|
Unit |
releasePointerCapture()
Releases the pointer capture.
If the window does not have pointer capture, this call will do nothing.
|
Boolean |
removeCallbacks(action: Runnable!)
Removes the specified Runnable from the message queue.
|
Unit |
removeOnAttachStateChangeListener(listener: View.OnAttachStateChangeListener!)
Remove a listener for attach state changes. The listener will receive no further notification of window attach/detach events.
|
Unit |
removeOnLayoutChangeListener(listener: View.OnLayoutChangeListener!)
Remove a listener for layout changes.
|
Unit |
removeOnUnhandledKeyEventListener(listener: View.OnUnhandledKeyEventListener!)
Removes a listener which will receive unhandled KeyEvent s. This must be called on the UI thread.
|
Unit |
requestApplyInsets()
Ask that a new dispatch of onApplyWindowInsets(android.view.WindowInsets) be performed.
|
Unit |
requestFitSystemWindows()
Ask that a new dispatch of fitSystemWindows(android.graphics.Rect) be performed.
|
Boolean |
requestFocus()
Call this to try to give focus to a specific view or to one of its descendants. A view will not actually take focus if it is not focusable (isFocusable returns false), or if it can't be focused due to other conditions (not focusable in touch mode (isFocusableInTouchMode ) while the device is in touch mode, not visible, not enabled, or has no size). See also focusSearch(int) , which is what you call to say that you have focus, and you want your parent to look for the next one. This is equivalent to calling requestFocus(int,android.graphics.Rect) with arguments FOCUS_DOWN and null .
|
Boolean |
requestFocus(direction: Int)
Call this to try to give focus to a specific view or to one of its descendants and give it a hint about what direction focus is heading. A view will not actually take focus if it is not focusable (isFocusable returns false), or if it is focusable and it is not focusable in touch mode (isFocusableInTouchMode ) while the device is in touch mode. See also focusSearch(int) , which is what you call to say that you have focus, and you want your parent to look for the next one. This is equivalent to calling requestFocus(int,android.graphics.Rect) with null set for the previously focused rectangle.
|
Boolean |
requestFocus(direction: Int, previouslyFocusedRect: Rect!)
Call this to try to give focus to a specific view or to one of its descendants and give it hints about the direction and a specific rectangle that the focus is coming from. The rectangle can help give larger views a finer grained hint about where focus is coming from, and therefore, where to show selection, or forward focus change internally. A view will not actually take focus if it is not focusable (isFocusable returns false), or if it is focusable and it is not focusable in touch mode (isFocusableInTouchMode ) while the device is in touch mode. A View will not take focus if it is not visible. A View will not take focus if one of its parents has android.view.ViewGroup#getDescendantFocusability() equal to ViewGroup#FOCUS_BLOCK_DESCENDANTS . See also focusSearch(int) , which is what you call to say that you have focus, and you want your parent to look for the next one. You may wish to override this method if your custom View has an internal View that it wishes to forward the request to.
|
Boolean |
requestFocusFromTouch()
Call this to try to give focus to a specific view or to one of its descendants. This is a special variant of requestFocus() that will allow views that are not focusable in touch mode to request focus when they are touched.
|
Unit |
requestLayout()
Call this when something has changed which has invalidated the layout of this view. This will schedule a layout pass of the view tree. This should not be called while the view hierarchy is currently in a layout pass (isInLayout() . If layout is happening, the request may be honored at the end of the current layout pass (and then layout will run again) or after the current frame is drawn and the next layout occurs.
Subclasses which override this method should call the superclass method to handle possible request-during-layout errors correctly.
If you override this method you must call through to the superclass implementation.
|
Unit |
requestPointerCapture()
Requests pointer capture mode.
When the window has pointer capture, the mouse pointer icon will disappear and will not change its position. Enabling pointer capture will change the behavior of input devices in the following ways:
When pointer capture changes, connected mouse and trackpad devices may be reconfigured, and their properties (such as their sources or motion ranges) may change. Use an android.hardware.input.InputManager.InputDeviceListener to be notified when a device changes (which may happen after enabling or disabling pointer capture), and use InputDevice#getDevice(int) to get the updated InputDevice .
Events captured through pointer capture will be dispatched to OnCapturedPointerListener#onCapturedPointer(View, MotionEvent) if an OnCapturedPointerListener is set, and otherwise to onCapturedPointerEvent(android.view.MotionEvent) .
If the window already has pointer capture, this call does nothing.
The capture may be released through releasePointerCapture() , or will be lost automatically when the window loses focus.
|
Boolean |
requestRectangleOnScreen(rectangle: Rect!)
Request that a rectangle of this view be visible on the screen, scrolling if necessary just enough.
A View should call this if it maintains some notion of which part of its content is interesting. For example, a text editing view should call this when its cursor moves.
The Rectangle passed into this method should be in the View's content coordinate space. It should not be affected by which part of the View is currently visible or its scroll position.
|
Boolean |
requestRectangleOnScreen(rectangle: Rect!, immediate: Boolean)
Request that a rectangle of this view be visible on the screen, scrolling if necessary just enough.
A View should call this if it maintains some notion of which part of its content is interesting. For example, a text editing view should call this when its cursor moves.
The Rectangle passed into this method should be in the View's content coordinate space. It should not be affected by which part of the View is currently visible or its scroll position.
When immediate is set to true, scrolling will not be animated.
|
Unit |
requestUnbufferedDispatch(event: MotionEvent!)
Request unbuffered dispatch of the given stream of MotionEvents to this View. Until this View receives a corresponding MotionEvent#ACTION_UP , ask that the input system not batch MotionEvent s but instead deliver them as soon as they're available. This method should only be called for touch events.
This API is not intended for most applications. Buffered dispatch provides many of benefits, and just requesting unbuffered dispatch on most MotionEvent streams will not improve your input latency. Side effects include: increased latency, jittery scrolls and inability to take advantage of system resampling. Talk to your input professional to see if requestUnbufferedDispatch(android.view.MotionEvent) is right for you.
To receive unbuffered events for arbitrary input device source classes, use requestUnbufferedDispatch(int) ,
|
Unit |
requestUnbufferedDispatch(source: Int)
Request unbuffered dispatch of the given event source class to this view. This is similar to View#requestUnbufferedDispatch(MotionEvent) , but does not automatically terminate, and allows the specification of arbitrary input source classes.
Prior to android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE , calling this method will not result in any behavioral changes when this View is not attached to a window.
|
T |
requireViewById(id: Int)
Finds the first descendant view with the given ID, the view itself if the ID matches getId() , or throws an IllegalArgumentException if the ID is invalid or there is no matching view in the hierarchy.
Note: In most cases -- depending on compiler support -- the resulting view is automatically cast to the target class type. If the target class type is unconstrained, an explicit cast may be necessary.
|
Unit |
resetPivot()
Clears any pivot previously set by a call to setPivotX(float) or setPivotY(float) . After calling this isPivotSet() will be false and the pivot used for rotation will return to default of being centered on the view.
|
Int |
resolveSize(size: Int, measureSpec: Int)
Version of resolveSizeAndState(int,int,int) returning only the MEASURED_SIZE_MASK bits of the result.
|
Int |
resolveSizeAndState(size: Int, measureSpec: Int, childMeasuredState: Int)
Utility to reconcile a desired size and state, with constraints imposed by a MeasureSpec. Will take the desired size, unless a different size is imposed by the constraints. The returned value is a compound integer, with the resolved size in the 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.
|
Boolean |
restoreDefaultFocus()
Gives focus to the default-focus view in the view hierarchy that has this view as a root. If the default-focus view cannot be found, falls back to calling requestFocus(int) .
|
Unit |
restoreHierarchyState(container: SparseArray<Parcelable!>!)
Restore this view hierarchy's frozen state from the given container.
|
Unit |
saveAttributeDataForStyleable(context: Context, styleable: IntArray, attrs: AttributeSet?, t: TypedArray, defStyleAttr: Int, defStyleRes: Int)
Stores debugging information about attributes. This should be called in a constructor by every 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.
|
Unit |
saveHierarchyState(container: SparseArray<Parcelable!>!)
Store this view hierarchy's frozen state into the given container.
|
Unit |
scheduleDrawable(who: Drawable, what: Runnable, when: Long)
Schedules an action on a drawable to occur at a specified time.
|
Unit |
scrollBy(x: Int, y: Int)
Move the scrolled position of your view. This will cause a call to onScrollChanged(int,int,int,int) and the view will be invalidated.
|
Unit |
scrollTo(x: Int, y: Int)
Set the scrolled position of your view. This will cause a call to onScrollChanged(int,int,int,int) and the view will be invalidated.
|
Unit |
sendAccessibilityEvent(eventType: Int)
Sends an accessibility event of the given type. If accessibility is not enabled this method has no effect. The default implementation calls onInitializeAccessibilityEvent(android.view.accessibility.AccessibilityEvent) first to populate information about the event source (this View), then calls dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent) to populate the text content of the event source including its descendants, then for events type AccessibilityEvent#TYPE_VIEW_SCROLLED and AccessibilityEvent#TYPE_WINDOW_CONTENT_CHANGED with subtype AccessibilityEvent#CONTENT_CHANGE_TYPE_STATE_DESCRIPTION , throttle the events, and last calls ViewParent#requestSendAccessibilityEvent(View, AccessibilityEvent) on its parent to request sending of the event to interested parties.
If an AccessibilityDelegate has been specified via calling setAccessibilityDelegate(android.view.View.AccessibilityDelegate) its AccessibilityDelegate#sendAccessibilityEvent(View, int) is responsible for handling this call.
If this view uses AccessibilityNodeProvider to provide virtual view hierarchy rooted at this view, this method should not be called to send events from virtual children because it will populate the events with wrong information and the events should be throttled per child instead at the virtual root level. To send events from virtual children, call ViewParent#requestSendAccessibilityEvent(View, AccessibilityEvent) on the view's parent to request sending of the event to interested parties.
|
Unit |
sendAccessibilityEventUnchecked(event: AccessibilityEvent!)
This method behaves exactly as sendAccessibilityEvent(int) but takes as an argument an empty AccessibilityEvent and does not perform a check whether accessibility is enabled.
If an AccessibilityDelegate has been specified via calling setAccessibilityDelegate(android.view.View.AccessibilityDelegate) its AccessibilityDelegate#sendAccessibilityEventUnchecked(View, AccessibilityEvent) is responsible for handling this call.
|
Unit |
setAccessibilityDataSensitive(accessibilityDataSensitive: Int)
Specifies whether this view should only allow interactions from android.accessibilityservice.AccessibilityService s with the android.accessibilityservice.AccessibilityServiceInfo#isAccessibilityTool property set to true.
|
Unit |
setAccessibilityDelegate(delegate: View.AccessibilityDelegate?)
Sets a delegate for implementing accessibility support via composition (as opposed to inheritance). For more details, see AccessibilityDelegate .
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 AccessibilityDelegate#onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfo) , 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.
|
Unit |
setAccessibilityHeading(isHeading: Boolean)
Set if view is a heading for a section of content for accessibility purposes.
Users of some accessibility services can choose to navigate between headings instead of between paragraphs, words, etc. Apps that provide headings on sections of text can help the text navigation experience.
Note: Use androidx.core.view.ViewCompat#setAccessibilityHeading(View, boolean) for backwards-compatibility.
|
Unit |
setAccessibilityLiveRegion(mode: Int)
Sets the live region mode for this view. This indicates to accessibility services whether they should automatically notify the user about changes to the view's content description or text, or to the content descriptions or text of the view's children (where applicable).
Different priority levels are available:
-
ACCESSIBILITY_LIVE_REGION_POLITE : Indicates that updates to the region should be presented to the user. Suitable in most cases for prominent updates within app content that don't require the user's immediate attention.
-
ACCESSIBILITY_LIVE_REGION_ASSERTIVE : Indicates that updates to the region have the highest priority and should be presented to the user immediately. This may result in disruptive notifications from an accessibility service, which may potentially interrupt other feedback or user actions, so it should generally be used only for critical, time-sensitive information.
-
ACCESSIBILITY_LIVE_REGION_NONE : Disables change announcements (the default for most views).
Examples:
- Selecting an option in a dropdown menu updates a panel below with the updated content. This panel may be marked as a live region with
ACCESSIBILITY_LIVE_REGION_POLITE to notify users of the change. A screen reader may queue changes as announcements that don't disrupt ongoing speech.
- An emergency alert may be marked with
ACCESSIBILITY_LIVE_REGION_ASSERTIVE to immediately inform users of the emergency.
For error notifications, like an "incorrect password" warning in a login screen, views should send a AccessibilityEvent#TYPE_WINDOW_CONTENT_CHANGED AccessibilityEvent with a content change type AccessibilityEvent#CONTENT_CHANGE_TYPE_ERROR and set AccessibilityNodeInfo#setError(CharSequence) . Custom widgets should provide error-setting methods that support accessibility. For example, use android.widget.TextView#setError(CharSequence) instead of explicitly sending events.
Don't use live regions for frequently-updating UI elements (e.g., progress bars), as this can overwhelm the user with feedback from accessibility services. If necessary, use AccessibilityNodeInfo#setMinDurationBetweenContentChanges(Duration) to throttle feedback and reduce disruptions.
Note: Use androidx.core.view.ViewCompat#setAccessibilityLiveRegion(View, int) for backwards-compatibility.
|
Unit |
setAccessibilityPaneTitle(accessibilityPaneTitle: CharSequence?)
Visually distinct portion of a window with window-like semantics are considered panes for accessibility purposes. One example is the content view of a large fragment that is replaced. In order for accessibility services to understand a pane's window-like behavior, panes should have descriptive titles. Views with pane titles produce AccessibilityEvent#TYPE_WINDOW_STATE_CHANGED s when they appear, disappear, or change title.
When transitioning from one Activity to another, instead of using setAccessibilityPaneTitle() , set a descriptive title for its window by using android:label for the matching Activity entry in your application's manifest or updating the title at runtime with android.app.Activity#setTitle(CharSequence) .
Note: Use androidx.core.view.ViewCompat#setAccessibilityPaneTitle(View, CharSequence) for backwards-compatibility.
|
Unit |
setAccessibilityTraversalAfter(afterId: Int)
Sets the id of a view that screen readers are requested to visit before this view.
For example, if view B should be visited after A, with B.setAccessibilityTraversalAfter(A), then this requests that screen readers visit and traverse view A before visiting view B.
Note: Views are visited in the order determined by the screen reader. Avoid explicitly manipulating focus order, as this may result in inconsistent user experiences between apps. Instead, use other semantics, such as restructuring the view hierarchy layout, to communicate order.
Setting this view to be after a view that is not important for accessibility, or if this view is not important for accessibility, means this method will have no effect if the service is not aware of unimportant views.
To avoid a risk of loops, set clear relationships between views. For example, if focus order should be B -> A, and B.setAccessibilityTraversalBefore(A), then also call A.setAccessibilityTraversalAfter(B).
|
Unit |
setAccessibilityTraversalBefore(beforeId: Int)
Sets the id of a view that screen readers are requested to visit after this view.
For example, if view B should be visited before view A, with B.setAccessibilityTraversalBefore(A), this requests that screen readers visit and traverse view B before visiting view A.
Note: Views are visited in the order determined by the screen reader. Avoid explicitly manipulating focus order, as this may result in inconsistent user experiences between apps. Instead, use other semantics, such as restructuring the view hierarchy layout, to communicate order.
Setting this view to be after a view that is not important for accessibility, or if this view is not important for accessibility, means this method will have no effect if the service is not aware of unimportant views.
To avoid a risk of loops, set clear relationships between views. For example, if focus order should be B -> A, and B.setAccessibilityTraversalBefore(A), then also call A.setAccessibilityTraversalAfter(B).
|
Unit |
setActivated(activated: Boolean)
Changes the activated state of this view. A view can be activated or not. Note that activation is not the same as selection. Selection is a transient property, representing the view (hierarchy) the user is currently interacting with. Activation is a longer-term state that the user can move views in and out of. For example, in a list view with single or multiple selection enabled, the views in the current selection set are activated. (Um, yeah, we are deeply sorry about the terminology here.) The activated state is propagated down to children of the view it is set on.
|
Unit |
setAllowClickWhenDisabled(clickableWhenDisabled: Boolean)
Enables or disables click events for this view when disabled.
|
Unit |
setAllowedHandwritingDelegatePackage(allowedPackageName: String?)
Specifies that this view may act as a handwriting initiation delegator for a delegate editor view from the specified package. If this method is not called, delegators may only be used to initiate handwriting mode for a delegate editor view from the same package as the delegator view. This method allows specifying a different trusted package which may contain a delegate editor view linked to this delegator view.
This method has no effect unless setHandwritingDelegatorCallback is also called to configure this view to act as a handwriting delegator.
If this method is called on the delegator view, then setAllowedHandwritingDelegatorPackage should also be called on the delegate editor view.
For example, to configure a delegator view in package 1:
delegatorView.setHandwritingDelegatorCallback(callback);
delegatorView.setAllowedHandwritingDelegatePackage(package2);
Then to configure the corresponding delegate editor view in package 2:
delegateEditorView.setIsHandwritingDelegate(true);
delegateEditorView.setAllowedHandwritingDelegatorPackage(package1);
|
Unit |
setAllowedHandwritingDelegatorPackage(allowedPackageName: String?)
Specifies that a view from the specified package may act as a handwriting delegator for this delegate editor view. If this method is not called, only views from the same package as this delegate editor view may act as a handwriting delegator. This method allows specifying a different trusted package which may contain a delegator view linked to this delegate editor view.
This method has no effect unless setIsHandwritingDelegate is also called to configure this view to act as a handwriting delegate.
If this method is called on the delegate editor view, then setAllowedHandwritingDelegatePackage should also be called on the delegator view.
|
Unit |
setAlpha(alpha: Float)
Sets the opacity of the view to a value from 0 to 1, where 0 means the view is completely transparent and 1 means the view is completely opaque.
Note: 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.
For a view with a frequently changing alpha, such as during a fading animation, it is strongly recommended for performance reasons to either override hasOverlappingRendering() to return false if appropriate, or setting a layer type on the view for the duration of the animation. On versions android.os.Build.VERSION_CODES#M and below, the default path for rendering an unlayered View with alpha could add multiple milliseconds of rendering cost, even for simple or small views. Starting with android.os.Build.VERSION_CODES#M , LAYER_TYPE_HARDWARE is automatically applied to the view at the rendering level.
If this view overrides onSetAlpha(int) to return true, then this view is responsible for applying the opacity itself.
On versions android.os.Build.VERSION_CODES#LOLLIPOP_MR1 and below, note that if the view is backed by a layer and is associated with a layer paint , setting an alpha value less than 1.0 will supersede the alpha of the layer paint.
Starting with android.os.Build.VERSION_CODES#M , setting a translucent alpha value will clip a View to its bounds, unless the View returns false from hasOverlappingRendering .
|
Unit |
setAnimation(animation: Animation!)
Sets the next animation to play for this view. If you want the animation to play immediately, use startAnimation(android.view.animation.Animation) instead. This method provides allows fine-grained control over the start time and invalidation, but you must make sure that 1) the animation has a start time set, and 2) the view's parent (which controls animations on its children) will be invalidated when the animation is supposed to start.
|
Unit |
setAnimationMatrix(matrix: Matrix?)
Changes the transformation matrix on the view. This is used in animation frameworks, such as android.transition.Transition . When the animation finishes, the matrix should be cleared by calling this method with null as the matrix parameter. Application developers should use transformation methods like setRotation(float) , setScaleX(float) , setScaleX(float) , setTranslationX(float) } and setTranslationY(float) (float)}} instead.
|
Unit |
setAutoHandwritingEnabled(enabled: Boolean)
Set whether this view enables automatic handwriting initiation. For a view with an active InputConnection , if auto handwriting is enabled then stylus movement within its view boundary will automatically trigger the handwriting mode. Check android.view.inputmethod.InputMethodManager#startStylusHandwriting(View) for more details about handwriting mode. If the View wants to initiate handwriting mode by itself, it can set this field to false and call android.view.inputmethod.InputMethodManager#startStylusHandwriting(View) when there is stylus movement detected. Note that this attribute has no effect on the View's children. For example, if a ViewGroup disables auto handwriting but its children set auto handwriting to true, auto handwriting will still work for the children, and vice versa.
|
Unit |
setAutofillHints(vararg autofillHints: String!)
Sets the hints that help an android.service.autofill.AutofillService determine how to autofill the view with the user's data.
Typically, there is only one way to autofill a view, but there could be more than one. For example, if the application accepts either an username or email address to identify an user.
These hints are not validated by the Android System, but passed "as is" to the service. Hence, they can have any value, but it's recommended to use the AUTOFILL_HINT_ constants such as: AUTOFILL_HINT_USERNAME , AUTOFILL_HINT_PASSWORD , AUTOFILL_HINT_EMAIL_ADDRESS , AUTOFILL_HINT_NAME , AUTOFILL_HINT_PHONE , AUTOFILL_HINT_POSTAL_ADDRESS , AUTOFILL_HINT_POSTAL_CODE , AUTOFILL_HINT_CREDIT_CARD_NUMBER , AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE , AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE , AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY , AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH or AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR .
|
Unit |
setAutofillId(id: AutofillId?)
Sets the unique, logical identifier of this view in the activity, for autofill purposes.
The autofill id is created on demand, and this method should only be called when a view is reused after dispatchProvideAutofillStructure(android.view.ViewStructure,int) is called, as that method creates a snapshot of the view that is passed along to the autofill service.
This method is typically used when view subtrees are recycled to represent different content* —in this case, the autofill id can be saved before the view content is swapped out, and restored later when it's swapped back in. For example:
EditText reusableView = ...;
ViewGroup parentView = ...;
AutofillManager afm = ...;
// Swap out the view and change its contents
AutofillId oldId = reusableView.getAutofillId();
CharSequence oldText = reusableView.getText();
parentView.removeView(reusableView);
AutofillId newId = afm.getNextAutofillId();
reusableView.setText("New I am");
reusableView.setAutofillId(newId);
parentView.addView(reusableView);
// Later, swap the old content back in
parentView.removeView(reusableView);
reusableView.setAutofillId(oldId);
reusableView.setText(oldText);
parentView.addView(reusableView);
NOTE: If this view is a descendant of an android.widget.AdapterView , the system may reset its autofill id when this view is recycled. If the autofill ids need to be stable, they should be set again in android.widget.Adapter#getView(int, android.view.View, android.view.ViewGroup) .
|
Unit |
setBackground(background: Drawable!)
Set the background to a given Drawable, or remove the background. If the background has padding, this 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 use setPadding(int,int,int,int) .
|
Unit |
setBackgroundColor(color: Int)
Sets the background color for this view.
|
Unit |
setBackgroundDrawable(background: Drawable!)
|
Unit |
setBackgroundResource(resid: Int)
Set the background to a given resource. The resource should refer to a Drawable object or 0 to remove the background.
|
Unit |
setBackgroundTintBlendMode(blendMode: BlendMode?)
Specifies the blending mode used to apply the tint specified by setBackgroundTintList(android.content.res.ColorStateList) } to the background drawable. The default mode is BlendMode#SRC_IN .
|
Unit |
setBackgroundTintList(tint: ColorStateList?)
Applies a tint to the background drawable. Does not modify the current tint mode, which is BlendMode#SRC_IN by default.
Subsequent calls to setBackground(android.graphics.drawable.Drawable) will automatically mutate the drawable and apply the specified tint and tint mode using Drawable#setTintList(ColorStateList) .
|
Unit |
setBackgroundTintMode(tintMode: PorterDuff.Mode?)
Specifies the blending mode used to apply the tint specified by setBackgroundTintList(android.content.res.ColorStateList) } to the background drawable. The default mode is PorterDuff.Mode#SRC_IN .
|
Unit |
setBottom(bottom: Int)
Sets the bottom position of this view relative to its parent. This method is meant to be called by the layout system and should not generally be called otherwise, because the property may be changed at any time by the layout.
|
Unit |
setCameraDistance(distance: Float)
Sets the distance along the Z axis (orthogonal to the X/Y plane on which views are drawn) from the camera to this view. The camera's distance affects 3D transformations, for instance rotations around the X and Y axis. If the rotationX or rotationY properties are changed and this view is large (more than half the size of the screen), it is recommended to always use a camera distance that's greater than the height (X axis rotation) or the width (Y axis rotation) of this view.
The distance of the camera from the view plane can have an affect on the perspective distortion of the view when it is rotated around the x or y axis. For example, a large distance will result in a large viewing angle, and there will not be much perspective distortion of the view as it rotates. A short distance may cause much more perspective distortion upon rotation, and can also result in some drawing artifacts if the rotated view ends up partially behind the camera (which is why the recommendation is to use a distance at least as far as the size of the view, if the view is to be rotated.)
The distance is expressed in "depth pixels." The default distance depends on the screen density. For instance, on a medium density display, the default distance is 1280. On a high density display, the default distance is 1920.
If you want to specify a distance that leads to visually consistent results across various densities, use the following formula:
float scale = context.getResources().getDisplayMetrics().density;
view.setCameraDistance(distance * scale);
The density scale factor of a high density display is 1.5, and 1920 = 1280 * 1.5.
|
Unit |
setClickable(clickable: Boolean)
Enables or disables click events for this view. When a view is clickable it will change its state to "pressed" on every click. Subclasses should set the view clickable to visually react to user's clicks.
|
Unit |
setClipBounds(clipBounds: Rect!)
Sets a rectangular area on this view to which the view will be clipped when it is drawn. Setting the value to null will remove the clip bounds and the view will draw normally, using its full bounds.
|
Unit |
setClipToOutline(clipToOutline: Boolean)
Sets whether the View's Outline should be used to clip the contents of the View.
Only a single non-rectangular clip can be applied on a View at any time. Circular clips from a circular reveal animation take priority over Outline clipping, and child Outline clipping takes priority over Outline clipping done by a parent.
Note that this flag will only be respected if the View's Outline returns true from Outline#canClip() .
|
Unit |
setContentCaptureSession(contentCaptureSession: ContentCaptureSession?)
Sets the (optional) ContentCaptureSession associated with this view.
This method should be called when you need to associate a ContentCaptureContext to the content capture events associated with this view or its view hierarchy (if it's a ViewGroup ).
For example, if your activity is associated with a web domain, first you would need to set the context for the main DOM:
ContentCaptureSession mainSession = rootView.getContentCaptureSession();
mainSession.setContentCaptureContext(ContentCaptureContext.forLocusId(Uri.parse(myUrl));
Then if the page had an IFRAME , you would create a new session for it:
ContentCaptureSession iframeSession = mainSession.createContentCaptureSession(
ContentCaptureContext.forLocusId(Uri.parse(iframeUrl)));
iframeView.setContentCaptureSession(iframeSession);
|
Unit |
setContentDescription(contentDescription: CharSequence!)
Sets the View 's content description.
A content description briefly describes the view and is primarily used for accessibility support to determine how a view should be presented to the user. In the case of a view with no textual representation, such as android.widget.ImageButton , a useful content description explains what the view does. For example, an image button with a phone icon that is used to place a call may use "Call" as its content description. An image of a floppy disk that is used to save a file may use "Save".
This should omit role or state. Role refers to the kind of user-interface element the View is, such as a Button or Checkbox. State refers to a frequently changing property of the View, such as an On/Off state of a button or the audio level of a volume slider.
Content description updates are not frequent, and are used when the semantic content - not the state - of the element changes. For example, a Play button might change to a Pause button during music playback.
|
Unit |
setContentSensitivity(mode: Int)
Sets content sensitivity mode to determine whether this view displays sensitive content (e.g. username, password etc.). The system will improve user privacy i.e. hide content drawn by a sensitive view from screen sharing and recording.
The window hosting a sensitive view will be marked as secure during an active media projection session. This would be equivalent to applying android.view.WindowManager.LayoutParams#FLAG_SECURE to the window.
|
Unit |
setContextClickable(contextClickable: Boolean)
Enables or disables context clicking for this view. This event can launch the listener.
|
Unit |
setDefaultFocusHighlightEnabled(defaultFocusHighlightEnabled: Boolean)
Sets whether this View should use a default focus highlight when it gets focused but doesn't have android.R.attr#state_focused defined in its background.
|
Unit |
setDrawingCacheBackgroundColor(color: Int)
Setting a solid background color for the drawing cache's bitmaps will improve performance and memory usage. Note, though that this should only be used if this view will always be drawn on top of a solid color.
|
Unit |
setDrawingCacheEnabled(enabled: Boolean)
Enables or disables the drawing cache. When the drawing cache is enabled, the next call to getDrawingCache() or buildDrawingCache() will draw the view in a bitmap. Calling draw(android.graphics.Canvas) will not draw from the cache when the cache is enabled. To benefit from the cache, you must request the drawing cache by calling getDrawingCache() and draw it on screen if the returned bitmap is not null.
Enabling the drawing cache is similar to setting a layer when hardware acceleration is turned off. When hardware acceleration is turned on, enabling the drawing cache has no effect on rendering because the system uses a different mechanism for acceleration which ignores the flag. If you want to use a Bitmap for the view, even when hardware acceleration is enabled, see setLayerType(int,android.graphics.Paint) for information on how to enable software and hardware layers.
This API can be used to manually generate a bitmap copy of this view, by setting the flag to true and calling getDrawingCache() .
|
Unit |
setDrawingCacheQuality(quality: Int)
Set the drawing cache quality of this view. This value is used only when the drawing cache is enabled
|
Unit |
setDuplicateParentStateEnabled(enabled: Boolean)
Enables or disables the duplication of the parent's state into this view. When duplication is enabled, this view gets its drawable state from its parent rather than from its own internal properties.
Note: in the current implementation, setting this property to true after the view was added to a ViewGroup might have no effect at all. This property should always be used from XML or set to true before adding this view to a ViewGroup.
Note: if this view's parent addStateFromChildren property is enabled and this property is enabled, an exception will be thrown.
Note: if the child view uses and updates additional states which are unknown to the parent, these states should not be affected by this method.
|
Unit |
setElevation(elevation: Float)
Sets the base elevation of this view, in pixels.
|
Unit |
setEnabled(enabled: Boolean)
Set the enabled state of this view. The interpretation of the enabled state varies by subclass.
|
Unit |
setFadingEdgeLength(length: Int)
Set the size of the faded edge used to indicate that more content in this view is available. Will not change whether the fading edge is enabled; use setVerticalFadingEdgeEnabled(boolean) or setHorizontalFadingEdgeEnabled(boolean) to enable the fading edge for the vertical or horizontal fading edges.
|
Unit |
setFilterTouchesWhenObscured(enabled: Boolean)
Sets whether the framework should discard touches when the view's window is obscured by another visible window at the touched location. Refer to the View security documentation for more details.
|
Unit |
setFitsSystemWindows(fitSystemWindows: Boolean)
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 fitSystemWindows(android.graphics.Rect) will be executed. See that method for more details.
Note that if you are providing your own implementation of fitSystemWindows(android.graphics.Rect) , then there is no need to set this flag to true -- your implementation will be overriding the default implementation that checks this flag.
|
Unit |
setFocusable(focusable: Boolean)
Set whether this view can receive the focus.
Setting this to false will also ensure that this view is not focusable in touch mode.
|
Unit |
setFocusable(focusable: Int)
Sets whether this view can receive focus.
Setting this to FOCUSABLE_AUTO tells the framework to determine focusability automatically based on the view's interactivity. This is the default.
Setting this to NOT_FOCUSABLE will ensure that this view is also not focusable in touch mode.
|
Unit |
setFocusableInTouchMode(focusableInTouchMode: Boolean)
Set whether this view can receive focus while in touch mode. Setting this to true will also ensure that this view is focusable.
|
Unit |
setFocusedByDefault(isFocusedByDefault: Boolean)
Sets whether this View should receive focus when the focus is restored for the view hierarchy containing this view.
Focus gets restored for a view hierarchy when the root of the hierarchy gets added to a window or serves as a target of cluster navigation.
|
Unit |
setForceDarkAllowed(allow: Boolean)
Sets whether or not to allow force dark to apply to this view. Setting this to false will disable the auto-dark feature on everything this view draws, including any descendants. Setting this to true will allow this view to be automatically made dark, however a value of 'true' will not override any 'false' value in its parent chain nor will it prevent any 'false' in any of its children. The default behavior of force dark is also influenced by the Theme's isLightTheme attribute. If a theme is isLightTheme="false", then force dark is globally disabled for that theme.
|
Unit |
setForeground(foreground: Drawable!)
Supply a Drawable that is to be rendered on top of all of the content in the view.
|
Unit |
setForegroundGravity(gravity: Int)
Describes how the foreground is positioned. Defaults to START and TOP.
|
Unit |
setForegroundTintBlendMode(blendMode: BlendMode?)
Specifies the blending mode used to apply the tint specified by setForegroundTintList(android.content.res.ColorStateList) } to the background drawable. The default mode is BlendMode#SRC_IN .
|
Unit |
setForegroundTintList(tint: ColorStateList?)
Applies a tint to the foreground drawable. Does not modify the current tint mode, which is PorterDuff.Mode#SRC_IN by default.
Subsequent calls to setForeground(android.graphics.drawable.Drawable) will automatically mutate the drawable and apply the specified tint and tint mode using Drawable#setTintList(ColorStateList) .
|
Unit |
setForegroundTintMode(tintMode: PorterDuff.Mode?)
Specifies the blending mode used to apply the tint specified by setForegroundTintList(android.content.res.ColorStateList) } to the background drawable. The default mode is PorterDuff.Mode#SRC_IN .
|
Unit |
setFrameContentVelocity(pixelsPerSecond: Float)
Set the current velocity of the View, we only track positive value. We will use the velocity information to adjust the frame rate when applicable. For example, we could potentially lower the frame rate when the velocity of a fling gesture becomes slower. Note that this is only valid till the next drawn frame.
|
Unit |
setHandwritingBoundsOffsets(offsetLeft: Float, offsetTop: Float, offsetRight: Float, offsetBottom: Float)
Set the amount of offset applied to this view's stylus handwriting bounds. A positive offset will offset the edge outwards.The base handwriting bounds of a view is its visible bounds. The handwriting bounds offsets are applied to the base handwriting bounds to determine the final handwriting bounds.
This method is mainly used to enlarge the view's handwriting bounds for a better user experience.
Note that when the view is clipped (e.g. the view is in a android.widget.ScrollView ), the offsets are applied after the view's handwriting bounds is clipped.
|
Unit |
setHandwritingDelegateFlags(flags: Int)
Sets flags configuring the handwriting delegation behavior for this delegate editor view.
This method has no effect unless setIsHandwritingDelegate is also called to configure this view to act as a handwriting delegate.
|
Unit |
setHandwritingDelegatorCallback(callback: Runnable?)
Sets a callback which should be called when a stylus MotionEvent occurs within this view's bounds. The callback will be called from the UI thread.
Setting a callback allows this view to act as a handwriting delegator, so that handwriting mode for a delegate editor view can be initiated by stylus movement on this delegator view. The callback implementation is expected to show and focus the delegate editor view. If a view which returns true for isHandwritingDelegate() creates an input connection while the same stylus MotionEvent sequence is ongoing, handwriting mode will be initiated for that view.
A common use case is a custom view which looks like a text editor but does not actually support text editing itself, and clicking on the custom view causes an EditText to be shown. To support handwriting initiation in this case, this method can be called on the custom view to configure it as a delegator. The EditText should call setIsHandwritingDelegate to set it as a delegate. The callback implementation is typically the same as the click listener implementation which shows the EditText.
If null is passed, this view will no longer act as a handwriting initiation delegator.
|
Unit |
setHapticFeedbackEnabled(hapticFeedbackEnabled: Boolean)
Set whether this view should have haptic feedback for events such as long presses.
You may wish to disable haptic feedback if your view already controls its own haptic feedback.
|
Unit |
setHasTransientState(hasTransientState: Boolean)
Set whether this view is currently tracking transient state that the framework should attempt to preserve when possible. This flag is reference counted, so every call to setHasTransientState(true) should be paired with a later call to setHasTransientState(false).
A view with transient state cannot be trivially rebound from an external data source, such as an adapter binding item views in a list. This may be because the view is performing an animation, tracking user selection of content, or similar.
|
Unit |
setHorizontalFadingEdgeEnabled(horizontalFadingEdgeEnabled: Boolean)
Define whether the horizontal edges should be faded when this view is scrolled horizontally.
|
Unit |
setHorizontalScrollBarEnabled(horizontalScrollBarEnabled: Boolean)
Define whether the horizontal scrollbar should be drawn or not. The scrollbar is not drawn by default.
|
Unit |
setHorizontalScrollbarThumbDrawable(drawable: Drawable?)
Defines the horizontal thumb drawable
|
Unit |
setHorizontalScrollbarTrackDrawable(drawable: Drawable?)
Defines the horizontal track drawable
|
Unit |
setHovered(hovered: Boolean)
Sets whether the view is currently hovered.
Calling this method also changes the drawable state of the view. This enables the view to react to hover by using different drawable resources to change its appearance.
The onHoverChanged method is called when the hovered state changes.
|
Unit |
setId(id: Int)
Sets the identifier for this view. The identifier does not have to be unique in this view's hierarchy. The identifier should be a positive number.
|
Unit |
setImportantForAccessibility(mode: Int)
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.
|
Unit |
setImportantForAutofill(mode: Int)
Sets the mode for determining whether this view is considered important for autofill.
The platform determines the importance for autofill automatically but you can use this method to customize the behavior. For example:
- When the view contents is irrelevant for autofill (for example, a text field used in a "Captcha" challenge), it should be
IMPORTANT_FOR_AUTOFILL_NO .
- When both the view and its children are irrelevant for autofill (for example, the root view of an activity containing a spreadhseet editor), it should be
IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS .
- When the view content is relevant for autofill but its children aren't (for example, a credit card expiration date represented by a custom view that overrides the proper autofill methods and has 2 children representing the month and year), it should be
IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS .
Note: Setting the mode as IMPORTANT_FOR_AUTOFILL_NO or IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS does not guarantee the view (and its children) will not be used for autofill purpose; for example, when the user explicitly makes an autofill request, all views are included in the ViewStructure, and starting in android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE the system uses other factors along with importance to determine the autofill behavior. See isImportantForAutofill() for more details about how the View's importance for autofill is used.
|
Unit |
setImportantForContentCapture(mode: Int)
Sets the mode for determining whether this view is considered important for content capture.
The platform determines the importance for autofill automatically but you can use this method to customize the behavior. Typically, a view that provides text should be marked as IMPORTANT_FOR_CONTENT_CAPTURE_YES .
|
Unit |
setIsCredential(isCredential: Boolean)
Sets whether this view is a credential for Credential Manager purposes.
See isCredential() .
|
Unit |
setIsHandwritingDelegate(isHandwritingDelegate: Boolean)
Sets this view to be a handwriting delegate. If a delegate view creates an input connection while a stylus MotionEvent sequence from a delegator view is ongoing, handwriting mode will be initiated for the delegate view.
|
Unit |
setKeepScreenOn(keepScreenOn: Boolean)
Controls whether the screen should remain on, modifying the value of KEEP_SCREEN_ON .
|
Unit |
setKeyboardNavigationCluster(isCluster: Boolean)
Set whether this view is a root of a keyboard navigation cluster.
|
Unit |
setLabelFor(id: Int)
Sets the id of a view for which this view serves as a label for accessibility purposes.
|
Unit |
setLayerPaint(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 ). Changed properties of the Paint provided to setLayerType(int,android.graphics.Paint) will be used the next time the View is redrawn, but setLayerPaint(android.graphics.Paint) must be called to ensure that the view gets redrawn immediately.
A layer is associated with an optional android.graphics.Paint instance that controls how the layer is composed on screen. The following properties of the paint are taken into account when composing the layer:
If this view has an alpha value set to < 1.0 by calling setAlpha(float) , the alpha value of the layer's paint is superseded by this view's alpha value.
|
Unit |
setLayerType(layerType: Int, paint: Paint?)
Specifies the type of layer backing this view. The layer can be LAYER_TYPE_NONE , LAYER_TYPE_SOFTWARE or LAYER_TYPE_HARDWARE .
A layer is associated with an optional android.graphics.Paint instance that controls how the layer is composed on screen. The following properties of the paint are taken into account when composing the layer:
If this view has an alpha value set to < 1.0 by calling setAlpha(float) , the alpha value of the layer's paint is superseded by this view's alpha value.
Refer to the documentation of LAYER_TYPE_NONE , LAYER_TYPE_SOFTWARE and LAYER_TYPE_HARDWARE for more information on when and how to use layers.
|
Unit |
setLayoutDirection(layoutDirection: Int)
Set the layout direction for this view. This will propagate a reset of layout direction resolution to the view's children and resolve layout direction for this view.
|
Unit |
setLayoutParams(params: ViewGroup.LayoutParams!)
Set the layout parameters associated with this view. These supply parameters to the parent of this view specifying how it should be arranged. There are many subclasses of ViewGroup.LayoutParams, and these correspond to the different subclasses of ViewGroup that are responsible for arranging their children.
|
Unit |
setLeft(left: Int)
Sets the left position of this view relative to its parent. This method is meant to be called by the layout system and should not generally be called otherwise, because the property may be changed at any time by the layout.
|
Unit |
setLeftTopRightBottom(left: Int, top: Int, right: Int, bottom: Int)
Assign a size and position to this view. This method is meant to be used in animations only as it applies this position and size for the view only temporary and it can be changed back at any time by the layout.
|
Unit |
setLongClickable(longClickable: Boolean)
Enables or disables long click events for this view. When a view is long clickable it reacts to the user holding down the button for a longer duration than a tap. This event can either launch the listener or a context menu.
|
Unit |
setMeasuredDimension(measuredWidth: Int, measuredHeight: Int)
This method must be called by onMeasure(int,int) to store the measured width and measured height. Failing to do so will trigger an exception at measurement time.
|
Unit |
setMinimumHeight(minHeight: Int)
Sets the minimum height of the view. It is not guaranteed the view will be able to achieve this minimum height (for example, if its parent layout constrains it with less available height).
|
Unit |
setMinimumWidth(minWidth: Int)
Sets the minimum width of the view. It is not guaranteed the view will be able to achieve this minimum width (for example, if its parent layout constrains it with less available width).
|
Unit |
setNestedScrollingEnabled(enabled: Boolean)
Enable or disable nested scrolling for this view.
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.
|
Unit |
setNextClusterForwardId(nextClusterForwardId: Int)
Sets the id of the view to use as the root of the next keyboard navigation cluster.
|
Unit |
setNextFocusDownId(nextFocusDownId: Int)
Sets the id of the view to use when the next focus is FOCUS_DOWN .
|
Unit |
setNextFocusForwardId(nextFocusForwardId: Int)
Sets the id of the view to use when the next focus is FOCUS_FORWARD .
|
Unit |
setNextFocusLeftId(nextFocusLeftId: Int)
Sets the id of the view to use when the next focus is FOCUS_LEFT .
|
Unit |
setNextFocusRightId(nextFocusRightId: Int)
Sets the id of the view to use when the next focus is FOCUS_RIGHT .
|
Unit |
setNextFocusUpId(nextFocusUpId: Int)
Sets the id of the view to use when the next focus is FOCUS_UP .
|
Unit |
setOnApplyWindowInsetsListener(listener: View.OnApplyWindowInsetsListener!)
Set an OnApplyWindowInsetsListener to take over the policy for applying window insets to this view. The listener's onApplyWindowInsets method will be called instead of the view's onApplyWindowInsets method.
|
Unit |
setOnCapturedPointerListener(l: View.OnCapturedPointerListener!)
Set a listener to receive callbacks when the pointer capture state of a view changes.
|
Unit |
setOnClickListener(l: View.OnClickListener?)
Register a callback to be invoked when this view is clicked. If this view is not clickable, it becomes clickable.
|
Unit |
setOnContextClickListener(l: View.OnContextClickListener?)
Register a callback to be invoked when this view is context clicked. If the view is not context clickable, it becomes context clickable.
|
Unit |
setOnCreateContextMenuListener(l: View.OnCreateContextMenuListener!)
Register a callback to be invoked when the context menu for this view is being built. If this view is not long clickable, it becomes long clickable.
|
Unit |
setOnDragListener(l: View.OnDragListener!)
Register a drag event listener callback object for this View. The parameter is an implementation of android.view.View.OnDragListener . To send a drag event to a View, the system calls the android.view.View.OnDragListener#onDrag(View,DragEvent) method.
|
Unit |
setOnFocusChangeListener(l: View.OnFocusChangeListener!)
Register a callback to be invoked when focus of this view changed.
|
Unit |
setOnGenericMotionListener(l: View.OnGenericMotionListener!)
Register a callback to be invoked when a generic motion event is sent to this view.
|
Unit |
setOnHoverListener(l: View.OnHoverListener!)
Register a callback to be invoked when a hover event is sent to this view.
|
Unit |
setOnKeyListener(l: View.OnKeyListener!)
Register a callback to be invoked when a hardware key is pressed in this view. Key presses in software input methods will generally not trigger the methods of this listener.
|
Unit |
setOnLongClickListener(l: View.OnLongClickListener?)
Register a callback to be invoked when this view is clicked and held. If this view is not long clickable, it becomes long clickable.
|
Unit |
setOnReceiveContentListener(mimeTypes: Array<String!>?, listener: OnReceiveContentListener?)
Sets the listener to be used to handle insertion of content into this view.
Depending on the type of view, this listener may be invoked for different scenarios. For example, for an editable android.widget.TextView , this listener will be invoked for the following scenarios:
- Paste from the clipboard (e.g. "Paste" or "Paste as plain text" action in the insertion/selection menu)
- Content insertion from the keyboard (from
InputConnection#commitContent )
- Drag and drop (drop events from
onDragEvent )
- Autofill
- Selection replacement via
Intent#ACTION_PROCESS_TEXT
When setting a listener, clients must also declare the accepted MIME types. The listener will still be invoked even if the MIME type of the content is not one of the declared MIME types (e.g. if the user pastes content whose type is not one of the declared MIME types). In that case, the listener may reject the content (defer to the default platform behavior) or execute some other fallback logic (e.g. show an appropriate message to the user). The declared MIME types serve as a hint to allow different features to optionally alter their behavior. For example, a soft keyboard may optionally choose to hide its UI for inserting GIFs for a particular input field if the MIME types set here for that field don't include "image/gif" or "image/*".
Note: MIME type matching in the Android framework is case-sensitive, unlike formal RFC MIME types. As a result, you should always write your MIME types with lowercase letters, or use android.content.Intent#normalizeMimeType to ensure that it is converted to lowercase.
|
Unit |
setOnScrollChangeListener(l: View.OnScrollChangeListener!)
Register a callback to be invoked when the scroll X or Y positions of this view change.
Note: Some views handle scrolling independently from View and may have their own separate listeners for scroll-type events. For example, ListView allows clients to register an AbsListView.OnScrollListener to listen for changes in list scroll position.
|
Unit |
setOnSystemUiVisibilityChangeListener(l: View.OnSystemUiVisibilityChangeListener!)
Set a listener to receive callbacks when the visibility of the system bar changes.
|
Unit |
setOnTouchListener(l: View.OnTouchListener!)
Register a callback to be invoked when a touch event is sent to this view.
|
Unit |
setOutlineAmbientShadowColor(color: Int)
Sets the color of the ambient shadow that is drawn when the view has a positive Z or elevation value.
By default the shadow color is black. Generally, this color will be opaque so the intensity of the shadow is consistent between different views with different colors.
The opacity of the final ambient shadow is a function of the shadow caster height, the alpha channel of the outlineAmbientShadowColor (typically opaque), and the android.R.attr#ambientShadowAlpha theme attribute.
|
Unit |
setOutlineProvider(provider: ViewOutlineProvider!)
Sets the ViewOutlineProvider of the view, which generates the Outline that defines the shape of the shadow it casts, and enables outline clipping.
The default ViewOutlineProvider, ViewOutlineProvider#BACKGROUND , queries the Outline from the View's background drawable, via Drawable#getOutline(Outline) . Changing the outline provider with this method allows this behavior to be overridden.
If the ViewOutlineProvider is null, if querying it for an outline returns false, or if the produced Outline is Outline#isEmpty() , shadows will not be cast.
Only outlines that return true from Outline#canClip() may be used for clipping.
|
Unit |
setOutlineSpotShadowColor(color: Int)
Sets the color of the spot shadow that is drawn when the view has a positive Z or elevation value.
By default the shadow color is black. Generally, this color will be opaque so the intensity of the shadow is consistent between different views with different colors.
The opacity of the final spot shadow is a function of the shadow caster height, the alpha channel of the outlineSpotShadowColor (typically opaque), and the android.R.attr#spotShadowAlpha theme attribute.
|
Unit |
setOverScrollMode(overScrollMode: Int)
Set the over-scroll mode for this view. Valid over-scroll modes are OVER_SCROLL_ALWAYS , 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.
|
Unit |
setPadding(left: Int, top: Int, right: Int, bottom: Int)
Sets the padding. The view may add on the space required to display the scrollbars, depending on the style and visibility of the scrollbars. So the values returned from getPaddingLeft , getPaddingTop , getPaddingRight and getPaddingBottom may be different from the values set in this call.
|
Unit |
setPaddingRelative(start: Int, top: Int, end: Int, bottom: Int)
Sets the relative padding. The view may add on the space required to display the scrollbars, depending on the style and visibility of the scrollbars. So the values returned from getPaddingStart , getPaddingTop , getPaddingEnd and getPaddingBottom may be different from the values set in this call.
|
Unit |
setPendingCredentialRequest(request: GetCredentialRequest, callback: OutcomeReceiver<GetCredentialResponse!, GetCredentialException!>)
Sets a CredentialManager request to retrieve credentials, when the user focuses on this given view. When this view is focused, the given request will be fired to CredentialManager , which will fetch content from all android.service.credentials.CredentialProviderService services on the device, and then display credential options to the user on a relevant UI (dropdown, keyboard suggestions etc.). When the user selects a credential, the final GetCredentialResponse will be propagated to the given callback . Developers are expected to handle the response programmatically and perform a relevant action, e.g. signing in the user.
For details on how to build a Credential Manager request, please see GetCredentialRequest .
This API should be called at any point before the user focuses on the view, e.g. during onCreate of an Activity.
|
Unit |
setPivotX(pivotX: Float)
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 the explicitly set pivotX and pivotY values.
|
Unit |
setPivotY(pivotY: Float)
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 the explicitly set pivotX and pivotY values.
|
Unit |
setPointerIcon(pointerIcon: PointerIcon!)
Set the pointer icon to be used for a mouse pointer in the current view. Passing null will restore the pointer icon to its default value. Note that setting the pointer icon using this method will only set it for events coming from a mouse device (i.e. with source InputDevice#SOURCE_MOUSE ). To resolve the pointer icon for other device types like styluses, override onResolvePointerIcon(android.view.MotionEvent,int) .
|
Unit |
setPreferKeepClear(preferKeepClear: Boolean)
Set a preference to keep the bounds of this view clear from floating windows above this view's window. This informs the system that the view is considered a vital area for the user and that ideally it should not be covered. Setting this is only appropriate for UI where the user would likely take action to uncover it.
The system will try to respect this preference, but when not possible will ignore it.
Note: This is independent from setPreferKeepClearRects . If both are set, both will be taken into account.
|
Unit |
setPreferKeepClearRects(rects: MutableList<Rect!>)
Set a preference to keep the provided rects clear from floating windows above this view's window. This informs the system that these rects are considered vital areas for the user and that ideally they should not be covered. Setting this is only appropriate for UI where the user would likely take action to uncover it.
The system will try to respect this preference, but when not possible will ignore it.
Note: This is independent from setPreferKeepClear . If both are set, both will be taken into account.
|
Unit |
setPressed(pressed: Boolean)
Sets the pressed state for this view.
|
Unit |
setRenderEffect(renderEffect: RenderEffect?)
Configure the android.graphics.RenderEffect to apply to this View. This will apply a visual effect to the results of the View before it is drawn. For example if RenderEffect#createBlurEffect(float, float, RenderEffect, Shader.TileMode) is provided, the contents will be drawn in a separate layer, then this layer will be blurred when this View is drawn.
|
Unit |
setRequestedFrameRate(frameRate: Float)
You can set the preferred frame rate for a View using a positive number or by specifying the preferred frame rate category using constants, including REQUESTED_FRAME_RATE_CATEGORY_NO_PREFERENCE, REQUESTED_FRAME_RATE_CATEGORY_LOW, REQUESTED_FRAME_RATE_CATEGORY_NORMAL, REQUESTED_FRAME_RATE_CATEGORY_HIGH. Keep in mind that the preferred frame rate affects the frame rate for the next frame, so use this method carefully. It's important to note that the preference is valid as long as the View is invalidated.
|
Unit |
setRevealOnFocusHint(revealOnFocus: Boolean)
Sets this view's preference for reveal behavior when it gains focus.
When set to true, this is a signal to ancestor views in the hierarchy that this view would prefer to be brought fully into view when it gains focus. For example, a text field that a user is meant to type into. Other views such as scrolling containers may prefer to opt-out of this behavior.
The default value for views is true, though subclasses may change this based on their preferred behavior.
|
Unit |
setRight(right: Int)
Sets the right position of this view relative to its parent. This method is meant to be called by the layout system and should not generally be called otherwise, because the property may be changed at any time by the layout.
|
Unit |
setRotation(rotation: Float)
Sets the degrees that the view is rotated around the pivot point. Increasing values result in clockwise rotation.
|
Unit |
setRotationX(rotationX: Float)
Sets the degrees that the view is rotated around the horizontal axis through the pivot point. Increasing values result in clockwise rotation from the viewpoint of looking down the x axis. When rotating large views, it is recommended to adjust the camera distance accordingly. Refer to setCameraDistance(float) for more information.
|
Unit |
setRotationY(rotationY: Float)
Sets the degrees that the view is rotated around the vertical axis through the pivot point. Increasing values result in counter-clockwise rotation from the viewpoint of looking down the y axis. When rotating large views, it is recommended to adjust the camera distance accordingly. Refer to setCameraDistance(float) for more information.
|
Unit |
setSaveEnabled(enabled: Boolean)
Controls whether the saving of this view's state is enabled (that is, whether its onSaveInstanceState method will be called). Note that even if freezing is enabled, the view still must have an id assigned to it (via setId(int) ) for its state to be saved. This flag can only disable the saving of this view; any child views may still have their state saved.
|
Unit |
setSaveFromParentEnabled(enabled: Boolean)
Controls whether the entire hierarchy under this view will save its state when a state saving traversal occurs from its parent. The default is true; if false, these views will not be saved unless saveHierarchyState(android.util.SparseArray) is called directly on this view.
|
Unit |
setScaleX(scaleX: Float)
Sets the amount that the view is scaled in x around the pivot point, as a proportion of the view's unscaled width. A value of 1 means that no scaling is applied.
|
Unit |
setScaleY(scaleY: Float)
Sets the amount that the view is scaled in Y around the pivot point, as a proportion of the view's unscaled width. A value of 1 means that no scaling is applied.
|
Unit |
setScreenReaderFocusable(screenReaderFocusable: Boolean)
Sets whether this View should be a focusable element for screen readers and include non-focusable Views from its subtree when providing feedback.
Note: this is similar to using android:focusable , but does not impact input focus behavior.
|
Unit |
setScrollBarDefaultDelayBeforeFade(scrollBarDefaultDelayBeforeFade: Int)
Define the delay before scrollbars fade.
|
Unit |
setScrollBarFadeDuration(scrollBarFadeDuration: Int)
Define the scrollbar fade duration.
|
Unit |
setScrollBarSize(scrollBarSize: Int)
Define the scrollbar size.
|
Unit |
setScrollBarStyle(style: Int)
Specify the style of the scrollbars. The scrollbars can be overlaid or inset. When inset, they add to the padding of the view. And the scrollbars can be drawn inside the padding area or on the edge of the view. For example, if a view has a background drawable and you want to draw the scrollbars inside the padding specified by the drawable, you can use SCROLLBARS_INSIDE_OVERLAY or SCROLLBARS_INSIDE_INSET. If you want them to appear at the edge of the view, ignoring the padding, then you can use SCROLLBARS_OUTSIDE_OVERLAY or SCROLLBARS_OUTSIDE_INSET.
|
Unit |
setScrollCaptureCallback(callback: ScrollCaptureCallback?)
Sets the callback to receive scroll capture requests. This component is the adapter between the scroll capture API and application UI code. If no callback is set, the system may provide an implementation. Any value provided here will take precedence over a system version.
This view will be ignored when SCROLL_CAPTURE_HINT_EXCLUDE is set in its scrollCaptureHint , regardless whether a callback has been set.
It is recommended to set the scroll capture hint SCROLL_CAPTURE_HINT_INCLUDE when setting a custom callback to help ensure it is selected as the target.
|
Unit |
setScrollCaptureHint(hint: Int)
Sets the scroll capture hint for this View. These flags affect the search for a potential scroll capture targets.
|
Unit |
setScrollContainer(isScrollContainer: Boolean)
Change whether this view is one of the set of scrollable containers in its window. This will be used to determine whether the window can resize or must pan when a soft input area is open -- scrollable containers allow the window to use resize mode since the container will appropriately shrink.
|
Unit |
setScrollIndicators(indicators: Int)
Sets the state of all scroll indicators.
See setScrollIndicators(int,int) for usage information.
|
Unit |
setScrollIndicators(indicators: Int, mask: Int)
Sets the state of the scroll indicators specified by the mask. To change all scroll indicators at once, see setScrollIndicators(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: <ul> <li>{ #SCROLL_INDICATOR_TOP}</li> <li>{ #SCROLL_INDICATOR_BOTTOM}</li> <li>{ #SCROLL_INDICATOR_LEFT}</li> <li>{ #SCROLL_INDICATOR_RIGHT}</li> <li>{ #SCROLL_INDICATOR_START}</li> <li>{ #SCROLL_INDICATOR_END}</li> </ul> #setScrollIndicators(int) #getScrollIndicators() ref android.R.styleable#View_scrollIndicators indicators Value is either <code>0</code> or a combination of { android.view.View#SCROLL_INDICATOR_TOP}, { android.view.View#SCROLL_INDICATOR_BOTTOM}, { android.view.View#SCROLL_INDICATOR_LEFT}, { android.view.View#SCROLL_INDICATOR_RIGHT}, { android.view.View#SCROLL_INDICATOR_START}, and { android.view.View#SCROLL_INDICATOR_END} mask Value is either <code>0</code> or a combination of { android.view.View#SCROLL_INDICATOR_TOP}, { android.view.View#SCROLL_INDICATOR_BOTTOM}, { android.view.View#SCROLL_INDICATOR_LEFT}, { android.view.View#SCROLL_INDICATOR_RIGHT}, { android.view.View#SCROLL_INDICATOR_START}, and { android.view.View#SCROLL_INDICATOR_END} 23
|
Unit |
setScrollX(value: Int)
Set the horizontal scrolled position of your view. This will cause a call to onScrollChanged(int,int,int,int) and the view will be invalidated.
|
Unit |
setScrollY(value: Int)
Set the vertical scrolled position of your view. This will cause a call to onScrollChanged(int,int,int,int) and the view will be invalidated.
|
Unit |
setScrollbarFadingEnabled(fadeScrollbars: Boolean)
Define whether scrollbars will fade when the view is not scrolling.
|
Unit |
setSoundEffectsEnabled(soundEffectsEnabled: Boolean)
Set whether this view should have sound effects enabled for events such as clicking and touching.
You may wish to disable sound effects for a view if you already play sounds, for instance, a dial key that plays dtmf tones.
|
Unit |
setStateDescription(stateDescription: CharSequence?)
Sets the View 's state description.
A state description briefly describes the states of the view and is primarily used for accessibility support to determine how the states of a view should be presented to the user. It is a supplement to the boolean states (for example, checked/unchecked) and it is used for customized state description (for example, "wifi, connected, three bars"). State description changes frequently while content description should change less often. State description should be localized. For android widgets which have default state descriptions, app developers can call this method to override the state descriptions. Setting state description to null restores the default behavior.
|
Unit |
setStateListAnimator(stateListAnimator: StateListAnimator!)
Attaches the provided StateListAnimator to this View.
Any previously attached StateListAnimator will be detached.
|
Unit |
setSystemGestureExclusionRects(rects: MutableList<Rect!>)
Sets a list of areas within this view's post-layout coordinate space where the system should not intercept touch or other pointing device gestures. This method should be called by onLayout(boolean,int,int,int,int) or onDraw(android.graphics.Canvas) .
Use this to tell the system which specific sub-areas of a view need to receive gesture input in order to function correctly in the presence of global system gestures that may conflict. For example, if the system wishes to capture swipe-in-from-screen-edge gestures to provide system-level navigation functionality, a view such as a navigation drawer container can mark the left (or starting) edge of itself as requiring gesture capture priority using this API. The system may then choose to relax its own gesture recognition to allow the app to consume the user's gesture. It is not necessary for an app to register exclusion rects for broadly spanning regions such as the entirety of a ScrollView or for simple press and release click targets such as Button . Mark an exclusion rect when interacting with a view requires a precision touch gesture in a small area in either the X or Y dimension, such as an edge swipe or dragging a SeekBar thumb.
Note: the system will put a limit of 200dp on the vertical extent of the exclusions it takes into account. The limit does not apply while the navigation bar is stickily hidden, nor to the input method and home activity .
|
Unit |
setSystemUiVisibility(visibility: Int)
Request that the visibility of the status bar or other screen/window decorations be changed.
This method is used to put the over device UI into temporary modes where the user's attention is focused more on the application content, by dimming or hiding surrounding system affordances. This is typically used in conjunction with Window.FEATURE_ACTION_BAR_OVERLAY , allowing the applications content to be placed behind the action bar (and with these flags other system affordances) so that smooth transitions between hiding and showing them can be done.
Two representative examples of the use of system UI visibility is implementing a content browsing application (like a magazine reader) and a video playing application.
The first code shows a typical implementation of a View in a content browsing application. In this implementation, the application goes into a content-oriented mode by hiding the status bar and action bar, and putting the navigation elements into lights out mode. The user can then interact with content while in this mode. Such an application should provide an easy way for the user to toggle out of the mode (such as to check information in the status bar or access notifications). In the implementation here, this is done simply by tapping on the content.
This second code sample shows a typical implementation of a View in a video playing application. In this situation, while the video is playing the application would like to go into a complete full-screen mode, to use as much of the display as possible for the video. When in this state the user can not interact with the application; the system intercepts touching on the screen to pop the UI out of full screen mode. See fitSystemWindows(android.graphics.Rect) for a sample layout that goes with this code.
|
Unit |
setTag(tag: Any!)
Sets the tag associated with this view. A tag can be used to mark a view in its hierarchy and does not have to be unique within the hierarchy. Tags can also be used to store data within a view without resorting to another data structure.
|
Unit |
setTag(key: Int, tag: Any!)
Sets a tag associated with this view and a key. A tag can be used to mark a view in its hierarchy and does not have to be unique within the hierarchy. Tags can also be used to store data within a view without resorting to another data structure. The specified key should be an id declared in the resources of the application to ensure it is unique (see the ID resource type). Keys identified as belonging to the Android framework or not associated with any package will cause an IllegalArgumentException to be thrown.
|
Unit |
setTextAlignment(textAlignment: Int)
Set the text alignment.
|
Unit |
setTextDirection(textDirection: Int)
Set the text direction.
|
Unit |
setTooltipText(tooltipText: CharSequence?)
Sets the tooltip text which will be displayed in a small popup next to the view.
The tooltip will be displayed:
- On long click, unless it is handled otherwise (by OnLongClickListener or a context menu).
- On hover, after a brief delay since the pointer has stopped moving
Note: Do not override this method, as it will have no effect on the text displayed in the tooltip.
|
Unit |
setTop(top: Int)
Sets the top position of this view relative to its parent. This method is meant to be called by the layout system and should not generally be called otherwise, because the property may be changed at any time by the layout.
|
Unit |
setTouchDelegate(delegate: TouchDelegate!)
Sets the TouchDelegate for this View.
|
Unit |
setTransitionAlpha(alpha: Float)
This property is intended only for use by the Fade transition, which animates it to produce a visual translucency that does not side-effect (or get affected by) the real alpha property. This value is composited with the other alpha value (and the AlphaAnimation value, when that is present) to produce a final visual translucency result, which is what is passed into the DisplayList.
|
Unit |
setTransitionName(transitionName: String!)
Sets the name of the View to be used to identify Views in Transitions. Names should be unique in the View hierarchy.
|
Unit |
setTransitionVisibility(visibility: Int)
Changes the visibility of this View without triggering any other changes. This should only be used by animation frameworks, such as android.transition.Transition , where visibility changes should not adjust focus or trigger a new layout. Application developers should use setVisibility instead to ensure that the hierarchy is correctly updated.
Only call this method when a temporary visibility must be applied during an animation and the original visibility value is guaranteed to be reset after the animation completes. Use setVisibility in all other cases.
|
Unit |
setTranslationX(translationX: Float)
Sets the horizontal location of this view relative to its left position. This effectively positions the object post-layout, in addition to wherever the object's layout placed it.
|
Unit |
setTranslationY(translationY: Float)
Sets the vertical location of this view relative to its top position. This effectively positions the object post-layout, in addition to wherever the object's layout placed it.
|
Unit |
setTranslationZ(translationZ: Float)
Sets the depth location of this view relative to its elevation .
|
Unit |
setVerticalFadingEdgeEnabled(verticalFadingEdgeEnabled: Boolean)
Define whether the vertical edges should be faded when this view is scrolled vertically.
|
Unit |
setVerticalScrollBarEnabled(verticalScrollBarEnabled: Boolean)
Define whether the vertical scrollbar should be drawn or not. The scrollbar is not drawn by default.
|
Unit |
setVerticalScrollbarPosition(position: Int)
Set the position of the vertical scroll bar. Should be one of SCROLLBAR_POSITION_DEFAULT , SCROLLBAR_POSITION_LEFT or SCROLLBAR_POSITION_RIGHT .
|
Unit |
setVerticalScrollbarThumbDrawable(drawable: Drawable?)
Defines the vertical scrollbar thumb drawable
|
Unit |
setVerticalScrollbarTrackDrawable(drawable: Drawable?)
Defines the vertical scrollbar track drawable
|
Unit |
setViewTranslationCallback(callback: ViewTranslationCallback)
Sets a ViewTranslationCallback that is used to display/hide the translated information. Developers can provide the customized implementation for show/hide translated information.
|
Unit |
setWillNotCacheDrawing(willNotCacheDrawing: Boolean)
When a View's drawing cache is enabled, drawing is redirected to an offscreen bitmap. Some views, like an ImageView, must be able to bypass this mechanism if they already draw a single bitmap, to avoid unnecessary usage of the memory.
|
Unit |
setWillNotDraw(willNotDraw: Boolean)
If this view doesn't do any drawing on its own, set this flag to allow further optimizations. By default, this flag is not set on View, but could be set on some View subclasses such as ViewGroup. Typically, if you override onDraw(android.graphics.Canvas) you should clear this flag.
|
Unit |
setWindowInsetsAnimationCallback(callback: WindowInsetsAnimation.Callback?)
Sets a WindowInsetsAnimation.Callback to be notified about animations of windows that cause insets.
The callback's dispatch mode will affect whether animation callbacks are dispatched to the children of this view.
|
Unit |
setX(x: Float)
Sets the visual x position of this view, in pixels. This is equivalent to setting the translationX property to be the difference between the x value passed in and the current left property.
|
Unit |
setY(y: Float)
Sets the visual y position of this view, in pixels. This is equivalent to setting the translationY property to be the difference between the y value passed in and the current top property.
|
Unit |
setZ(z: Float)
Sets the visual z position of this view, in pixels. This is equivalent to setting the translationZ property to be the difference between the z value passed in and the current elevation property.
|
Boolean |
showContextMenu()
Shows the context menu for this view.
|
Boolean |
showContextMenu(x: Float, y: Float)
Shows the context menu for this view anchored to the specified view-relative coordinate.
|
ActionMode! |
startActionMode(callback: ActionMode.Callback!)
Start an action mode with the default type ActionMode#TYPE_PRIMARY .
|
ActionMode! |
startActionMode(callback: ActionMode.Callback!, type: Int)
Start an action mode with the given type.
|
Unit |
startAnimation(animation: Animation!)
Start the specified animation now.
|
Boolean |
startDrag(data: ClipData!, shadowBuilder: View.DragShadowBuilder!, myLocalState: Any!, flags: Int)
|
Boolean |
startDragAndDrop(data: ClipData!, shadowBuilder: View.DragShadowBuilder!, myLocalState: Any!, flags: Int)
Starts a drag and drop operation. When your application calls this method, it passes a android.view.View.DragShadowBuilder object to the system. The system calls this object's DragShadowBuilder#onProvideShadowMetrics(Point, Point) to get metrics for the drag shadow, and then calls the object's DragShadowBuilder#onDrawShadow(Canvas) to draw the drag shadow itself.
Once the system has the drag shadow, it begins the drag and drop operation by sending drag events to all the View objects in your application that are currently visible. It does this either by calling the View object's drag listener (an implementation of onDrag() or by calling the View object's onDragEvent() method. Both are passed a android.view.DragEvent object that has a android.view.DragEvent#getAction() value of android.view.DragEvent#ACTION_DRAG_STARTED .
Your application can invoke startDragAndDrop() on any attached View object. The View object does not need to be the one used in android.view.View.DragShadowBuilder , nor does it need to be related to the View the user selected for dragging.
|
Boolean |
startNestedScroll(axes: Int)
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 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() 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 ViewParent#onNestedScroll(View, int, int, int, int) .
|
Unit |
stopNestedScroll()
Stop a nested scroll in progress.
Calling this method when a nested scroll is not currently in progress is harmless.
|
String |
toString()
|
Unit |
transformMatrixToGlobal(matrix: Matrix)
Modifies the input matrix such that it maps view-local coordinates to on-screen coordinates.
|
Unit |
transformMatrixToLocal(matrix: Matrix)
Modifies the input matrix such that it maps on-screen coordinates to view-local coordinates.
|
Unit |
unscheduleDrawable(who: Drawable, what: Runnable)
Cancels a scheduled action on a drawable.
|
Unit |
unscheduleDrawable(who: Drawable!)
Unschedule any events associated with the given Drawable. This can be used when selecting a new Drawable into a view, so that the previous one is completely unscheduled.
|
Unit |
updateDragShadow(shadowBuilder: View.DragShadowBuilder!)
Updates the drag shadow for the ongoing drag and drop operation.
|
Boolean |
willNotCacheDrawing()
Returns whether or not this View can cache its drawing or not.
|
Boolean |
willNotDraw()
Returns whether or not this View draws on its own.
|