View
public
class
View
extends Object
implements
AccessibilityEventSource,
Drawable.Callback,
KeyEvent.Callback
java.lang.Object | |
↳ | android.view.View |
This class represents the basic building block for user interface components. A View
occupies a rectangular area on the screen and is responsible for drawing and
event handling. View is the base class for widgets, which are
used to create interactive UI components (buttons, text fields, etc.). The
ViewGroup
subclass is the base class for layouts, which
are invisible containers that hold other Views (or other ViewGroups) and define
their layout properties.
Developer Guides
For information about using this class to develop your application's user interface, read the User Interface developer guide.
Using Views
All of the views in a window are arranged in a single tree. You can add views either from code or by specifying a tree of views in one or more XML layout files. There are many specialized subclasses of views that act as controls or are capable of displaying text, images, or other content.
Once you have created a tree of views, there are typically a few types of common operations you may wish to perform:
- Set properties: for example setting the text of a
TextView
. The available properties and the methods that set them will vary among the different subclasses of views. Note that properties that are known at build time can be set in the XML layout files. - Set focus: The framework will handle moving focus in
response to user input. To force focus to a specific view, call
requestFocus()
. - Set up listeners: Views allow clients to set listeners
that will be notified when something interesting happens to the view. For
example, all views will let you set a listener to be notified when the view
gains or loses focus. You can register such a listener using
setOnFocusChangeListener(android.view.View.OnFocusChangeListener)
. Other view subclasses offer more specialized listeners. For example, a Button exposes a listener to notify clients when the button is clicked. - Set visibility: You can hide or show views using
setVisibility(int)
.
Note: The Android framework is responsible for measuring, laying out and
drawing views. You should not call methods that perform these actions on
views yourself unless you are actually implementing a
ViewGroup
.
Implementing a Custom View
To implement a custom view, you will usually begin by providing overrides for
some of the standard methods that the framework calls on all views. You do
not need to override all of these methods. In fact, you can start by just
overriding onDraw(android.graphics.Canvas)
.
Category | Methods | Description |
---|---|---|
Creation | Constructors | There is a form of the constructor that are called when the view is created from code and a form that is called when the view is inflated from a layout file. The second form should parse and apply any attributes defined in the layout file. |
|
Called after a view and all of its children has been inflated from XML. | |
Layout |
|
Called to determine the size requirements for this view and all of its children. |
|
Called when this view should assign a size and position to all of its children. | |
|
Called when the size of this view has changed. | |
Drawing |
|
Called when the view should render its content. |
Event processing |
|
Called when a new hardware key event occurs. |
|
Called when a hardware key up event occurs. | |
|
Called when a trackball motion event occurs. | |
|
Called when a motion event occurs with pointers down on the view. | |
|
Called when a generic motion event occurs. | |
|
Called when a hover motion event occurs. | |
Focus |
|
Called when the view gains or loses focus. |
|
Called when the window containing the view gains or loses focus. | |
Attaching |
|
Called when the view is attached to a window. |
|
Called when the view is detached from its window. | |
|
Called when the visibility of the window containing the view has changed. |
IDs
Views may have an integer id associated with them. These ids are typically assigned in the layout XML files, and are used to find specific views within the view tree. A common pattern is to:- Define a Button in the layout file and assign it a unique ID.
<Button android:id="@+id/my_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/my_button_text"/>
- From the onCreate method of an Activity, find the Button
Button myButton = findViewById(R.id.my_button);
View IDs need not be unique throughout the tree, but it is good practice to ensure that they are at least unique within the part of the tree you are searching.
Position
The geometry of a view is that of a rectangle. A view has a location, expressed as a pair of left and top coordinates, and two dimensions, expressed as a width and a height. The unit for location and dimensions is the pixel.
It is possible to retrieve the location of a view by invoking the methods
getLeft()
and getTop()
. The former returns the left, or X,
coordinate of the rectangle representing the view. The latter returns the
top, or Y, coordinate of the rectangle representing the view. These methods
both return the location of the view relative to its parent. For instance,
when getLeft() returns 20, that means the view is located 20 pixels to the
right of the left edge of its direct parent.
In addition, several convenience methods are offered to avoid unnecessary
computations, namely getRight()
and getBottom()
.
These methods return the coordinates of the right and bottom edges of the
rectangle representing the view. For instance, calling getRight()
is similar to the following computation: getLeft() + getWidth()
(see Size for more information about the width.)
Size, padding and margins
The size of a view is expressed with a width and a height. A view actually possess two pairs of width and height values.
The first pair is known as measured width and
measured height. These dimensions define how big a view wants to be
within its parent (see Layout for more details.) The
measured dimensions can be obtained by calling getMeasuredWidth()
and getMeasuredHeight()
.
The second pair is simply known as width and height, or
sometimes drawing width and drawing height. These
dimensions define the actual size of the view on screen, at drawing time and
after layout. These values may, but do not have to, be different from the
measured width and height. The width and height can be obtained by calling
getWidth()
and getHeight()
.
To measure its dimensions, a view takes into account its padding. The padding
is expressed in pixels for the left, top, right and bottom parts of the view.
Padding can be used to offset the content of the view by a specific amount of
pixels. For instance, a left padding of 2 will push the view's content by
2 pixels to the right of the left edge. Padding can be set using the
setPadding(int, int, int, int)
or setPaddingRelative(int, int, int, int)
method and queried by calling getPaddingLeft()
, getPaddingTop()
,
getPaddingRight()
, getPaddingBottom()
, getPaddingStart()
,
getPaddingEnd()
.
Even though a view can define a padding, it does not provide any support for
margins. However, view groups provide such a support. Refer to
ViewGroup
and
ViewGroup.MarginLayoutParams
for further information.
Layout
Layout is a two pass process: a measure pass and a layout pass. The measuring
pass is implemented in measure(int, int)
and is a top-down traversal
of the view tree. Each view pushes dimension specifications down the tree
during the recursion. At the end of the measure pass, every view has stored
its measurements. The second pass happens in
layout(int, int, int, int)
and is also top-down. During
this pass each parent is responsible for positioning all of its children
using the sizes computed in the measure pass.
When a view's measure() method returns, its getMeasuredWidth()
and
getMeasuredHeight()
values must be set, along with those for all of
that view's descendants. A view's measured width and measured height values
must respect the constraints imposed by the view's parents. This guarantees
that at the end of the measure pass, all parents accept all of their
children's measurements. A parent view may call measure() more than once on
its children. For example, the parent may measure each child once with
unspecified dimensions to find out how big they want to be, then call
measure() on them again with actual numbers if the sum of all the children's
unconstrained sizes is too big or too small.
The measure pass uses two classes to communicate dimensions. The
MeasureSpec
class is used by views to tell their parents how they
want to be measured and positioned. The base LayoutParams class just
describes how big the view wants to be for both width and height. For each
dimension, it can specify one of:
- an exact number
- MATCH_PARENT, which means the view wants to be as big as its parent (minus padding)
- WRAP_CONTENT, which means that the view wants to be just big enough to enclose its content (plus padding).
MeasureSpecs are used to push requirements down the tree from parent to child. A MeasureSpec can be in one of three modes:
- UNSPECIFIED: This is used by a parent to determine the desired dimension of a child view. For example, a LinearLayout may call measure() on its child with the height set to UNSPECIFIED and a width of EXACTLY 240 to find out how tall the child view wants to be given a width of 240 pixels.
- EXACTLY: This is used by the parent to impose an exact size on the child. The child must use this size, and guarantee that all of its descendants will fit within this size.
- AT_MOST: This is used by the parent to impose a maximum size on the child. The child must guarantee that it and all of its descendants will fit within this size.
To initiate a layout, call requestLayout()
. This method is typically
called by a view on itself when it believes that it can no longer fit within
its current bounds.
Drawing
Drawing is handled by walking the tree and recording the drawing commands of any View that needs to update. After this, the drawing commands of the entire tree are issued to screen, clipped to the newly damaged area.
The tree is largely recorded and drawn in order, with parents drawn before
(i.e., behind) their children, with siblings drawn in the order they appear
in the tree. If you set a background drawable for a View, then the View will
draw it before calling back to its onDraw()
method. The child
drawing order can be overridden with
custom child drawing order
in a ViewGroup, and with setZ(float)
custom Z values} set on Views.
To force a view to draw, call invalidate()
.
Event Handling and Threading
The basic cycle of a view is as follows:
- An event comes in and is dispatched to the appropriate view. The view handles the event and notifies any listeners.
- If in the course of processing the event, the view's bounds may need
to be changed, the view will call
requestLayout()
. - Similarly, if in the course of processing the event the view's appearance
may need to be changed, the view will call
invalidate()
. - If either
requestLayout()
orinvalidate()
were called, the framework will take care of measuring, laying out, and drawing the tree as appropriate.
Note: The entire view tree is single threaded. You must always be on
the UI thread when calling any method on any view.
If you are doing work on other threads and want to update the state of a view
from that thread, you should use a Handler
.
Focus Handling
The framework will handle routine focus movement in response to user input.
This includes changing the focus as views are removed or hidden, or as new
views become available. Views indicate their willingness to take focus
through the isFocusable()
method. To change whether a view can take
focus, call setFocusable(boolean)
. When in touch mode (see notes below)
views indicate whether they still would like focus via isFocusableInTouchMode()
and can change this via setFocusableInTouchMode(boolean)
.
Focus movement is based on an algorithm which finds the nearest neighbor in a given direction. In rare cases, the default algorithm may not match the intended behavior of the developer. In these situations, you can provide explicit overrides by using these XML attributes in the layout file:
nextFocusDown nextFocusLeft nextFocusRight nextFocusUp
To get a particular view to take focus, call requestFocus()
.
Touch Mode
When a user is navigating a user interface via directional keys such as a D-pad, it is necessary to give focus to actionable items such as buttons so the user can see what will take input. If the device has touch capabilities, however, and the user begins interacting with the interface by touching it, it is no longer necessary to always highlight, or give focus to, a particular view. This motivates a mode for interaction named 'touch mode'.
For a touch capable device, once the user touches the screen, the device
will enter touch mode. From this point onward, only views for which
isFocusableInTouchMode()
is true will be focusable, such as text editing widgets.
Other views that are touchable, like buttons, will not take focus when touched; they will
only fire the on click listeners.
Any time a user hits a directional key, such as a D-pad direction, the view device will exit touch mode, and find a view to take focus, so that the user may resume interacting with the user interface without touching the screen again.
The touch mode state is maintained across Activity
s. Call
isInTouchMode()
to see whether the device is currently in touch mode.
Scrolling
The framework provides basic support for views that wish to internally
scroll their content. This includes keeping track of the X and Y scroll
offset as well as mechanisms for drawing scrollbars. See
scrollBy(int, int)
, scrollTo(int, int)
, and
awakenScrollBars()
for more details.
Tags
Unlike IDs, tags are not used to identify views. Tags are essentially an extra piece of information that can be associated with a view. They are most often used as a convenience to store data related to views in the views themselves rather than by putting them in a separate structure.
Tags may be specified with character sequence values in layout XML as either
a single tag using the android:tag
attribute or multiple tags using the <tag>
child element:
<View ... android:tag="@string/mytag_value" /> <View ...> <tag android:id="@+id/mytag" android:value="@string/mytag_value" /> </View>
Tags may also be specified with arbitrary objects from code using
setTag(java.lang.Object)
or setTag(int, java.lang.Object)
.
Themes
By default, Views are created using the theme of the Context object supplied
to their constructor; however, a different theme may be specified by using
the android:theme
attribute in layout
XML or by passing a ContextThemeWrapper
to the constructor from
code.
When the android:theme
attribute is
used in XML, the specified theme is applied on top of the inflation
context's theme (see LayoutInflater
) and used for the view itself as
well as any child elements.
In the following example, both views will be created using the Material dark
color scheme; however, because an overlay theme is used which only defines a
subset of attributes, the value of
android:colorAccent
defined on
the inflation context's theme (e.g. the Activity theme) will be preserved.
<LinearLayout ... android:theme="@android:theme/ThemeOverlay.Material.Dark"> <View ...> </LinearLayout>
Properties
The View class exposes an ALPHA
property, as well as several transform-related
properties, such as TRANSLATION_X
and TRANSLATION_Y
. These properties are
available both in the Property
form as well as in similarly-named setter/getter
methods (such as setAlpha(float)
for ALPHA
). These properties can
be used to set persistent state associated with these rendering-related properties on the view.
The properties and methods can also be used in conjunction with
Animator
-based animations, described more in the
Animation section.
Animation
Starting with Android 3.0, the preferred way of animating views is to use the
android.animation
package APIs. These Animator
-based
classes change actual properties of the View object, such as alpha
and
translationX
. This behavior is contrasted to that of the pre-3.0
Animation
-based classes, which instead animate only
how the view is drawn on the display. In particular, the ViewPropertyAnimator
class
makes animating these View properties particularly easy and efficient.
Alternatively, you can use the pre-3.0 animation classes to animate how Views are rendered.
You can attach an Animation
object to a view using
setAnimation(android.view.animation.Animation)
or
startAnimation(android.view.animation.Animation)
. The animation can alter the scale,
rotation, translation and alpha of a view over time. If the animation is
attached to a view that has children, the animation will affect the entire
subtree rooted by that node. When an animation is started, the framework will
take care of redrawing the appropriate views until the animation completes.
Security
Sometimes it is essential that an application be able to verify that an action is being performed with the full knowledge and consent of the user, such as granting a permission request, making a purchase or clicking on an advertisement. Unfortunately, a malicious application could try to spoof the user into performing these actions, unaware, by concealing the intended purpose of the view. As a remedy, the framework offers a touch filtering mechanism that can be used to improve the security of views that provide access to sensitive functionality.
To enable touch filtering, call setFilterTouchesWhenObscured(boolean)
or set the
android:filterTouchesWhenObscured layout attribute to true. When enabled, the framework
will discard touches that are received whenever the view's window is obscured by
another visible window at the touched location. As a result, the view will not receive touches
whenever the touch passed through a toast, dialog or other window that appears above the view's
window.
For more fine-grained control over security, consider overriding the
onFilterTouchEventForSecurity(android.view.MotionEvent)
method to implement your own
security policy. See also MotionEvent.FLAG_WINDOW_IS_OBSCURED
.
See also:
Summary
Nested classes | |
---|---|
class |
View.AccessibilityDelegate
This class represents a delegate that can be registered in a |
class |
View.BaseSavedState
Base class for derived classes that want to save and restore their own
state in |
class |
View.DragShadowBuilder
Creates an image that the system displays during the drag and drop operation. |
class |
View.MeasureSpec
A MeasureSpec encapsulates the layout requirements passed from parent to child. |
interface |
View.OnApplyWindowInsetsListener
Listener for applying window insets on a view in a custom way. |
interface |
View.OnAttachStateChangeListener
Interface definition for a callback to be invoked when this view is attached or detached from its window. |
interface |
View.OnCapturedPointerListener
Interface definition for a callback to be invoked when a captured pointer event is being dispatched this view. |
interface |
View.OnClickListener
Interface definition for a callback to be invoked when a view is clicked. |
interface |
View.OnContextClickListener
Interface definition for a callback to be invoked when a view is context clicked. |
interface |
View.OnCreateContextMenuListener
Interface definition for a callback to be invoked when the context menu for this view is being built. |
interface |
View.OnDragListener
Interface definition for a listener that's invoked when a drag event is dispatched to this view. |
interface |
View.OnFocusChangeListener
Interface definition for a callback to be invoked when the focus state of a view changed. |
interface |
View.OnGenericMotionListener
Interface definition for a callback to be invoked when a generic motion event is dispatched to this view. |
interface |
View.OnHoverListener
Interface definition for a callback to be invoked when a hover event is dispatched to this view. |
interface |
View.OnKeyListener
Interface definition for a callback to be invoked when a hardware key event is dispatched to this view. |
interface |
View.OnLayoutChangeListener
Interface definition for a callback to be invoked when the layout bounds of a view changes due to layout processing. |
interface |
View.OnLongClickListener
Interface definition for a callback to be invoked when a view has been clicked and held. |
interface |
View.OnScrollChangeListener
Interface definition for a callback to be invoked when the scroll X or Y positions of a view change. |
interface |
View.OnSystemUiVisibilityChangeListener
This interface was deprecated
in API level 30.
Use |
interface |
View.OnTouchListener
Interface definition for a callback to be invoked when a touch event is dispatched to this view. |
interface |
View.OnUnhandledKeyEventListener
Interface definition for a callback to be invoked when a hardware key event hasn't been handled by the view hierarchy. |
XML attributes | |
---|---|
android:accessibilityHeading |
Whether or not this view is a heading for accessibility purposes. |
android:accessibilityLiveRegion |
Indicates to accessibility services whether the user should be notified when this view changes. |
android:accessibilityPaneTitle |
The title this view should present to accessibility as a pane title. |
android:accessibilityTraversalAfter |
Sets the id of a view that screen readers are requested to visit before this view. |
android:accessibilityTraversalBefore |
Sets the id of a view that screen readers are requested to visit after this view. |
android:allowClickWhenDisabled |
Whether or not allow clicks on disabled view. |
android:alpha |
alpha property of the view, as a value between 0 (completely transparent) and 1 (completely opaque). |
android:autoHandwritingEnabled |
Whether or not the auto handwriting initiation is enabled in this View. |
android:autofillHints |
Describes the content of a view so that a autofill service can fill in the appropriate data. |
android:autofilledHighlight |
Drawable to be drawn over the view to mark it as autofilled
May be a reference to another resource, in the form
" |
android:background |
A drawable to use as the background. |
android:backgroundTint |
Tint to apply to the background. |
android:backgroundTintMode |
Blending mode used to apply the background tint. |
android:clickable |
Defines whether this view reacts to click events. |
android:clipToOutline |
Whether the View's Outline should be used to clip the contents of the View. |
android:contentDescription |
Defines text that briefly describes content of the view. |
android:contextClickable |
Defines whether this view reacts to context click events. |
android:defaultFocusHighlightEnabled |
Whether this View should use a default focus highlight when it gets focused but
doesn't have R.attr.state_focused defined in its background.
|
android:drawingCacheQuality |
Defines the quality of translucent drawing caches. |
android:duplicateParentState |
When this attribute is set to true, the view gets its drawable state (focused, pressed, etc.) from its direct parent rather than from itself. |
android:elevation |
base z depth of the view. |
android:fadeScrollbars |
Defines whether to fade out scrollbars when they are not in use. |
android:fadingEdgeLength |
Defines the length of the fading edges. |
android:filterTouchesWhenObscured |
Specifies whether to filter touches when the view's window is obscured by another visible window. |
android:fitsSystemWindows |
Boolean internal attribute to adjust view layout based on system windows such as the status bar. |
android:focusable |
Controls whether a view can take focus. |
android:focusableInTouchMode |
Boolean that controls whether a view can take focus while in touch mode. |
android:focusedByDefault |
Whether this view is a default-focus view. |
android:forceHasOverlappingRendering |
Whether this view has elements that may overlap when drawn. |
android:foreground |
Defines the drawable to draw over the content. |
android:foregroundGravity |
Defines the gravity to apply to the foreground drawable. |
android:foregroundTint |
Tint to apply to the foreground. |
android:foregroundTintMode |
Blending mode used to apply the foreground tint. |
android:hapticFeedbackEnabled |
Boolean that controls whether a view should have haptic feedback enabled for events such as long presses. |
android:id |
Supply an identifier name for this view, to later retrieve it
with View.findViewById() or
Activity.findViewById() .
|
android:importantForAccessibility |
Describes whether or not this view is important for accessibility. |
android:importantForAutofill |
Hints the Android System whether the view node associated with this View should be included in a view structure used for autofill purposes. |
android:importantForContentCapture |
Hints the Android System whether the view node associated with this View should be use for content capture purposes. |
android:isCredential |
Boolean that hints the Android System that the view is credential and associated with
CredentialManager
May be a boolean value, such as " |
android:isScrollContainer |
Set this if the view will serve as a scrolling container, meaning that it can be resized to shrink its overall window so that there will be space for an input method. |
android:keepScreenOn |
Controls whether the view's window should keep the screen on while visible. |
android:keyboardNavigationCluster |
Whether this view is a root of a keyboard navigation cluster. |
android:layerType |
Specifies the type of layer backing this view. |
android:layoutDirection |
Defines the direction of layout drawing. |
android:longClickable |
Defines whether this view reacts to long click events. |
android:minHeight |
Defines the minimum height of the view. |
android:minWidth |
Defines the minimum width of the view. |
android:nextClusterForward |
Defines the next keyboard navigation cluster. |
android:nextFocusDown |
Defines the next view to give focus to when the next focus is
View.FOCUS_DOWN
If the reference refers to a view that does not exist or is part
of a hierarchy that is invisible, a RuntimeException
will result when the reference is accessed.
|
android:nextFocusForward |
Defines the next view to give focus to when the next focus is
View.FOCUS_FORWARD
If the reference refers to a view that does not exist or is part
of a hierarchy that is invisible, a RuntimeException
will result when the reference is accessed.
|
android:nextFocusLeft |
Defines the next view to give focus to when the next focus is
View.FOCUS_LEFT .
|
android:nextFocusRight |
Defines the next view to give focus to when the next focus is
View.FOCUS_RIGHT
If the reference refers to a view that does not exist or is part
of a hierarchy that is invisible, a RuntimeException
will result when the reference is accessed.
|
android:nextFocusUp |
Defines the next view to give focus to when the next focus is
View.FOCUS_UP
If the reference refers to a view that does not exist or is part
of a hierarchy that is invisible, a RuntimeException
will result when the reference is accessed.
|
android:onClick |
Name of the method in this View's context to invoke when the view is clicked. |
android:outlineAmbientShadowColor |
Sets the color of the ambient shadow that is drawn when the view has a positive Z or elevation value. |
android:outlineSpotShadowColor |
Sets the color of the spot shadow that is drawn when the view has a positive Z or elevation value. |
android:padding |
Sets the padding, in pixels, of all four edges. |
android:paddingBottom |
Sets the padding, in pixels, of the bottom edge; see R.attr.padding .
|
android:paddingEnd |
Sets the padding, in pixels, of the end edge; see R.attr.padding .
|
android:paddingHorizontal |
Sets the padding, in pixels, of the left and right edges; see
R.attr.padding .
|
android:paddingLeft |
Sets the padding, in pixels, of the left edge; see R.attr.padding .
|
android:paddingRight |
Sets the padding, in pixels, of the right edge; see R.attr.padding .
|
android:paddingStart |
Sets the padding, in pixels, of the start edge; see R.attr.padding .
|
android:paddingTop |
Sets the padding, in pixels, of the top edge; see R.attr.padding .
|
android:paddingVertical |
Sets the padding, in pixels, of the top and bottom edges; see
R.attr.padding .
|
android:preferKeepClear |
Sets a preference to keep the bounds of this view clear from floating windows above this view's window. |
android:requiresFadingEdge |
Defines which edges should be faded on scrolling. |
android:rotation |
rotation of the view, in degrees. |
android:rotationX |
rotation of the view around the x axis, in degrees. |
android:rotationY |
rotation of the view around the y axis, in degrees. |
android:saveEnabled |
If false, no state will be saved for this view when it is being frozen. |
android:scaleX |
scale of the view in the x direction. |
android:scaleY |
scale of the view in the y direction. |
android:screenReaderFocusable |
Whether this view should be treated as a focusable unit by screen reader accessibility tools. |
android:scrollIndicators |
Defines which scroll indicators should be displayed when the view can be scrolled. |
android:scrollX |
The initial horizontal scroll offset, in pixels. |
android:scrollY |
The initial vertical scroll offset, in pixels. |
android:scrollbarAlwaysDrawHorizontalTrack |
Defines whether the horizontal scrollbar track should always be drawn. |
android:scrollbarAlwaysDrawVerticalTrack |
Defines whether the vertical scrollbar track should always be drawn. |
android:scrollbarDefaultDelayBeforeFade |
Defines the delay in milliseconds that a scrollbar waits before fade out. |
android:scrollbarFadeDuration |
Defines the delay in milliseconds that a scrollbar takes to fade out. |
android:scrollbarSize |
Sets the width of vertical scrollbars and height of horizontal scrollbars. |
android:scrollbarStyle |
Controls the scrollbar style and position. |
android:scrollbarThumbHorizontal |
Defines the horizontal scrollbar thumb drawable. |
android:scrollbarThumbVertical |
Defines the vertical scrollbar thumb drawable. |
android:scrollbarTrackHorizontal |
Defines the horizontal scrollbar track drawable. |
android:scrollbarTrackVertical |
Defines the vertical scrollbar track drawable. |
android:scrollbars |
Defines which scrollbars should be displayed on scrolling or not. |
android:soundEffectsEnabled |
Boolean that controls whether a view should have sound effects enabled for events such as clicking and touching. |
android:stateListAnimator |
Sets the state-based animator for the View. |
android:supplementalDescription |
Provides brief supplemental information for the view, such as the purpose of the view when that purpose is not conveyed within its textual representation. |
android:tag |
Supply a tag for this view containing a String, to be retrieved
later with View.getTag() or
searched for with View.findViewWithTag() .
|
android:textAlignment |
Defines the alignment of the text. |
android:textDirection |
Defines the direction of the text. |
android:theme |
Specifies a theme override for a view. |
android:tooltipText |
Defines text displayed in a small popup window on hover or long press. |
android:transformPivotX |
x location of the pivot point around which the view will rotate and scale. |
android:transformPivotY |
y location of the pivot point around which the view will rotate and scale. |
android:transitionName |
Names a View such that it can be identified for Transitions. |
android:translationX |
translation in x of the view. |
android:translationY |
translation in y of the view. |
android:translationZ |
translation in z of the view. |
android:visibility |
Controls the initial visibility of the view. |
Constants | |
---|---|
int |
ACCESSIBILITY_DATA_SENSITIVE_AUTO
Automatically determine whether the view should only allow interactions from
|
int |
ACCESSIBILITY_DATA_SENSITIVE_NO
Allow interactions from all |
int |
ACCESSIBILITY_DATA_SENSITIVE_YES
Only allow interactions from |
int |
ACCESSIBILITY_LIVE_REGION_ASSERTIVE
Live region mode specifying that accessibility services should immediately notify users of changes to this view. |
int |
ACCESSIBILITY_LIVE_REGION_NONE
Live region mode specifying that accessibility services should not automatically announce changes to this view. |
int |
ACCESSIBILITY_LIVE_REGION_POLITE
Live region mode specifying that accessibility services should notify users of changes to this view. |
int |
AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS
Flag requesting you to add views that are marked as not important for autofill
(see |
String |
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE
Hint indicating that this view can be autofilled with a credit card expiration date. |
String |
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY
Hint indicating that this view can be autofilled with a credit card expiration day. |
String |
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH
Hint indicating that this view can be autofilled with a credit card expiration month. |
String |
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR
Hint indicating that this view can be autofilled with a credit card expiration year. |
String |
AUTOFILL_HINT_CREDIT_CARD_NUMBER
Hint indicating that this view can be autofilled with a credit card number. |
String |
AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE
Hint indicating that this view can be autofilled with a credit card security code. |
String |
AUTOFILL_HINT_EMAIL_ADDRESS
Hint indicating that this view can be autofilled with an email address. |
String |
AUTOFILL_HINT_NAME
Hint indicating that this view can be autofilled with a user's real name. |
String |
AUTOFILL_HINT_PASSWORD
Hint indicating that this view can be autofilled with a password. |
String |
AUTOFILL_HINT_PHONE
Hint indicating that this view can be autofilled with a phone number. |
String |
AUTOFILL_HINT_POSTAL_ADDRESS
Hint indicating that this view can be autofilled with a postal address. |
String |
AUTOFILL_HINT_POSTAL_CODE
Hint indicating that this view can be autofilled with a postal code. |
String |
AUTOFILL_HINT_USERNAME
Hint indicating that this view can be autofilled with a username. |
int |
AUTOFILL_TYPE_DATE
Autofill type for a field that contains a date, which is represented by a long representing
the number of milliseconds since the standard base time known as "the epoch", namely
January 1, 1970, 00:00:00 GMT (see |
int |
AUTOFILL_TYPE_LIST
Autofill type for a selection list field, which is filled by an |
int |
AUTOFILL_TYPE_NONE
Autofill type for views that cannot be autofilled. |
int |
AUTOFILL_TYPE_TEXT
Autofill type for a text field, which is filled by a |
int |
AUTOFILL_TYPE_TOGGLE
Autofill type for a togglable field, which is filled by a |
int |
CONTENT_SENSITIVITY_AUTO
Content sensitivity is determined by the framework. |
int |
CONTENT_SENSITIVITY_NOT_SENSITIVE
The view doesn't display sensitive content. |
int |
CONTENT_SENSITIVITY_SENSITIVE
The view displays sensitive content. |
int |
DRAG_FLAG_ACCESSIBILITY_ACTION
Flag indicating that the drag was initiated with
|
int |
DRAG_FLAG_GLOBAL
Flag indicating that a drag can cross window boundaries. |
int |
DRAG_FLAG_GLOBAL_PERSISTABLE_URI_PERMISSION
When this flag is used with |
int |
DRAG_FLAG_GLOBAL_PREFIX_URI_PERMISSION
When this flag is used with |
int |
DRAG_FLAG_GLOBAL_SAME_APPLICATION
Flag indicating that a drag can cross window boundaries (within the same application). |
int |
DRAG_FLAG_GLOBAL_URI_READ
When this flag is used with |
int |
DRAG_FLAG_GLOBAL_URI_WRITE
When this flag is used with |
int |
DRAG_FLAG_HIDE_CALLING_TASK_ON_DRAG_START
Flag indicating that this drag will result in the caller activity's task to be hidden for the duration of the drag, which means that the source activity will not receive drag events for the current drag gesture. |
int |
DRAG_FLAG_OPAQUE
Flag indicating that the drag shadow will be opaque. |
int |
DRAG_FLAG_START_INTENT_SENDER_ON_UNHANDLED_DRAG
Flag indicating that an unhandled drag should be delegated to the system to be started if no visible window wishes to handle the drop. |
int |
DRAWING_CACHE_QUALITY_AUTO
This constant was deprecated
in API level 28.
The view drawing cache was largely made obsolete with the introduction of
hardware-accelerated rendering in API 11. With hardware-acceleration, intermediate cache
layers are largely unnecessary and can easily result in a net loss in performance due to the
cost of creating and updating the layer. In the rare cases where caching layers are useful,
such as for alpha animations, |
int |
DRAWING_CACHE_QUALITY_HIGH
This constant was deprecated
in API level 28.
The view drawing cache was largely made obsolete with the introduction of
hardware-accelerated rendering in API 11. With hardware-acceleration, intermediate cache
layers are largely unnecessary and can easily result in a net loss in performance due to the
cost of creating and updating the layer. In the rare cases where caching layers are useful,
such as for alpha animations, |
int |
DRAWING_CACHE_QUALITY_LOW
This constant was deprecated
in API level 28.
The view drawing cache was largely made obsolete with the introduction of
hardware-accelerated rendering in API 11. With hardware-acceleration, intermediate cache
layers are largely unnecessary and can easily result in a net loss in performance due to the
cost of creating and updating the layer. In the rare cases where caching layers are useful,
such as for alpha animations, |
int |
FIND_VIEWS_WITH_CONTENT_DESCRIPTION
Find find views that contain the specified content description. |
int |
FIND_VIEWS_WITH_TEXT
Find views that render the specified text. |
int |
FOCUSABLE
This view wants keystrokes. |
int |
FOCUSABLES_ALL
View flag indicating whether |
int |
FOCUSABLES_TOUCH_MODE
View flag indicating whether |
int |
FOCUSABLE_AUTO
This view determines focusability automatically. |
int |
FOCUS_BACKWARD
Use with |
int |
FOCUS_DOWN
Use with |
int |
FOCUS_FORWARD
Use with |
int |
FOCUS_LEFT
Use with |
int |
FOCUS_RIGHT
Use with |
int |
FOCUS_UP
Use with |
int |
GONE
This view is invisible, and it doesn't take any space for layout purposes. |
int |
HAPTIC_FEEDBACK_ENABLED
View flag indicating whether this view should have haptic feedback enabled for events such as long presses. |
int |
IMPORTANT_FOR_ACCESSIBILITY_AUTO
Automatically determine whether a view is important for accessibility. |
int |
IMPORTANT_FOR_ACCESSIBILITY_NO
The view is not important for accessibility. |
int |
IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
The view is not important for accessibility, nor are any of its descendant views. |
int |
IMPORTANT_FOR_ACCESSIBILITY_YES
The view is important for accessibility. |
int |
IMPORTANT_FOR_AUTOFILL_AUTO
Automatically determine whether a view is important for autofill. |
int |
IMPORTANT_FOR_AUTOFILL_NO
The view is not important for autofill, but its children (if any) will be traversed. |
int |
IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS
The view is not important for autofill, and its children (if any) will not be traversed. |
int |
IMPORTANT_FOR_AUTOFILL_YES
The view is important for autofill, and its children (if any) will be traversed. |
int |
IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS
The view is important for autofill, but its children (if any) will not be traversed. |
int |
IMPORTANT_FOR_CONTENT_CAPTURE_AUTO
Automatically determine whether a view is important for content capture. |
int |
IMPORTANT_FOR_CONTENT_CAPTURE_NO
The view is not important for content capture, but its children (if any) will be traversed. |
int |
IMPORTANT_FOR_CONTENT_CAPTURE_NO_EXCLUDE_DESCENDANTS
The view is not important for content capture, and its children (if any) will not be traversed. |
int |
IMPORTANT_FOR_CONTENT_CAPTURE_YES
The view is important for content capture, and its children (if any) will be traversed. |
int |
IMPORTANT_FOR_CONTENT_CAPTURE_YES_EXCLUDE_DESCENDANTS
The view is important for content capture, but its children (if any) will not be traversed. |
int |
INVISIBLE
This view is invisible, but it still takes up space for layout purposes. |
int |
KEEP_SCREEN_ON
View flag indicating that the screen should remain on while the window containing this view is visible to the user. |
int |
LAYER_TYPE_HARDWARE
Indicates that the view has a hardware layer. |
int |
LAYER_TYPE_NONE
Indicates that the view does not have a layer. |
int |
LAYER_TYPE_SOFTWARE
Indicates that the view has a software layer. |
int |
LAYOUT_DIRECTION_INHERIT
Horizontal layout direction of this view is inherited from its parent. |
int |
LAYOUT_DIRECTION_LOCALE
Horizontal layout direction of this view is from deduced from the default language script for the locale. |
int |
LAYOUT_DIRECTION_LTR
Horizontal layout direction of this view is from Left to Right. |
int |
LAYOUT_DIRECTION_RTL
Horizontal layout direction of this view is from Right to Left. |
int |
MEASURED_HEIGHT_STATE_SHIFT
Bit shift of |
int |
MEASURED_SIZE_MASK
Bits of |
int |
MEASURED_STATE_MASK
Bits of |
int |
MEASURED_STATE_TOO_SMALL
Bit of |
int |
NOT_FOCUSABLE
This view does not want keystrokes. |
int |
NO_ID
Used to mark a View that has no ID. |
int |
OVER_SCROLL_ALWAYS
Always allow a user to over-scroll this view, provided it is a view that can scroll. |
int |
OVER_SCROLL_IF_CONTENT_SCROLLS
Allow a user to over-scroll this view only if the content is large enough to meaningfully scroll, provided it is a view that can scroll. |
int |
OVER_SCROLL_NEVER
Never allow a user to over-scroll this view. |
int |
RECTANGLE_ON_SCREEN_REQUEST_SOURCE_INPUT_FOCUS
Represents that the user interaction that is requesting a rectangle on screen is doing so because the View has input/keyboard focus. |
int |
RECTANGLE_ON_SCREEN_REQUEST_SOURCE_SCROLL_ONLY
Represents that the user interaction that is requesting a rectangle on screen is doing so only to scroll the View on screen, and the rectangle is not associated with a text cursor or keyboard focus. |
int |
RECTANGLE_ON_SCREEN_REQUEST_SOURCE_TEXT_CURSOR
Represents that the user interaction that is requesting a rectangle on screen is doing so because the View contains a text cursor (caret). |
int |
RECTANGLE_ON_SCREEN_REQUEST_SOURCE_UNDEFINED
Represents that the user interaction that is requesting a rectangle on screen is
doing so via the original |
float |
REQUESTED_FRAME_RATE_CATEGORY_DEFAULT
|
float |
REQUESTED_FRAME_RATE_CATEGORY_HIGH
|
float |
REQUESTED_FRAME_RATE_CATEGORY_LOW
|
float |
REQUESTED_FRAME_RATE_CATEGORY_NORMAL
|
float |
REQUESTED_FRAME_RATE_CATEGORY_NO_PREFERENCE
|
int |
SCREEN_STATE_OFF
Indicates that the screen has changed state and is now off. |
int |
SCREEN_STATE_ON
Indicates that the screen has changed state and is now on. |
int |
SCROLLBARS_INSIDE_INSET
The scrollbar style to display the scrollbars inside the padded area, increasing the padding of the view. |
int |
SCROLLBARS_INSIDE_OVERLAY
The scrollbar style to display the scrollbars inside the content area, without increasing the padding. |
int |
SCROLLBARS_OUTSIDE_INSET
The scrollbar style to display the scrollbars at the edge of the view, increasing the padding of the view. |
int |
SCROLLBARS_OUTSIDE_OVERLAY
The scrollbar style to display the scrollbars at the edge of the view, without increasing the padding. |
int |
SCROLLBAR_POSITION_DEFAULT
Position the scroll bar at the default position as determined by the system. |
int |
SCROLLBAR_POSITION_LEFT
Position the scroll bar along the left edge. |
int |
SCROLLBAR_POSITION_RIGHT
Position the scroll bar along the right edge. |
int |
SCROLL_AXIS_HORIZONTAL
Indicates scrolling along the horizontal axis. |
int |
SCROLL_AXIS_NONE
Indicates no axis of view scrolling. |
int |
SCROLL_AXIS_VERTICAL
Indicates scrolling along the vertical axis. |
int |
SCROLL_CAPTURE_HINT_AUTO
The content of this view will be considered for scroll capture if scrolling is possible. |
int |
SCROLL_CAPTURE_HINT_EXCLUDE
Explicitly exclude this view as a potential scroll capture target. |
int |
SCROLL_CAPTURE_HINT_EXCLUDE_DESCENDANTS
Explicitly exclude all children of this view as potential scroll capture targets. |
int |
SCROLL_CAPTURE_HINT_INCLUDE
Explicitly include this view as a potential scroll capture target. |
int |
SCROLL_INDICATOR_BOTTOM
Scroll indicator direction for the bottom edge of the view. |
int |
SCROLL_INDICATOR_END
Scroll indicator direction for the ending edge of the view. |
int |
SCROLL_INDICATOR_LEFT
Scroll indicator direction for the left edge of the view. |
int |
SCROLL_INDICATOR_RIGHT
Scroll indicator direction for the right edge of the view. |
int |
SCROLL_INDICATOR_START
Scroll indicator direction for the starting edge of the view. |
int |
SCROLL_INDICATOR_TOP
Scroll indicator direction for the top edge of the view. |
int |
SOUND_EFFECTS_ENABLED
View flag indicating whether this view should have sound effects enabled for events such as clicking and touching. |
int |
STATUS_BAR_HIDDEN
This constant was deprecated
in API level 15.
Use |
int |
STATUS_BAR_VISIBLE
This constant was deprecated
in API level 15.
Use |
int |
SYSTEM_UI_FLAG_FULLSCREEN
This constant was deprecated
in API level 30.
Use |
int |
SYSTEM_UI_FLAG_HIDE_NAVIGATION
This constant was deprecated
in API level 30.
Use |
int |
SYSTEM_UI_FLAG_IMMERSIVE
This constant was deprecated
in API level 30.
Use |
int |
SYSTEM_UI_FLAG_IMMERSIVE_STICKY
This constant was deprecated
in API level 30.
Use |
int |
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
This constant was deprecated
in API level 30.
For floating windows, use |
int |
SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
This constant was deprecated
in API level 30.
For floating windows, use |
int |
SYSTEM_UI_FLAG_LAYOUT_STABLE
This constant was deprecated
in API level 30.
Use |
int |
SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
This constant was deprecated
in API level 30.
Use |
int |
SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
This constant was deprecated
in API level 30.
Use |
int |
SYSTEM_UI_FLAG_LOW_PROFILE
This constant was deprecated
in API level 30.
Low profile mode is deprecated. Hide the system bars instead if the application
needs to be in a unobtrusive mode. Use |
int |
SYSTEM_UI_FLAG_VISIBLE
This constant was deprecated
in API level 30.
SystemUiVisibility flags are deprecated. Use |
int |
SYSTEM_UI_LAYOUT_FLAGS
This constant was deprecated in API level 30. System UI layout flags are deprecated. |
int |
TEXT_ALIGNMENT_CENTER
Center the paragraph, e.g. ALIGN_CENTER. |
int |
TEXT_ALIGNMENT_GRAVITY
Default for the root view. |
int |
TEXT_ALIGNMENT_INHERIT
Default text alignment. |
int |
TEXT_ALIGNMENT_TEXT_END
Align to the end of the paragraph, e.g. ALIGN_OPPOSITE. |
int |
TEXT_ALIGNMENT_TEXT_START
Align to the start of the paragraph, e.g. ALIGN_NORMAL. |
int |
TEXT_ALIGNMENT_VIEW_END
Align to the end of the view, which is ALIGN_RIGHT if the view's resolved layoutDirection is LTR, and ALIGN_LEFT otherwise. |
int |
TEXT_ALIGNMENT_VIEW_START
Align to the start of the view, which is ALIGN_LEFT if the view's resolved layoutDirection is LTR, and ALIGN_RIGHT otherwise. |
int |
TEXT_DIRECTION_ANY_RTL
Text direction is using "any-RTL" algorithm. |
int |
TEXT_DIRECTION_FIRST_STRONG
Text direction is using "first strong algorithm". |
int |
TEXT_DIRECTION_FIRST_STRONG_LTR
Text direction is using "first strong algorithm". |
int |
TEXT_DIRECTION_FIRST_STRONG_RTL
Text direction is using "first strong algorithm". |
int |
TEXT_DIRECTION_INHERIT
Text direction is inherited through |
int |
TEXT_DIRECTION_LOCALE
Text direction is coming from the system Locale. |
int |
TEXT_DIRECTION_LTR
Text direction is forced to LTR. |
int |
TEXT_DIRECTION_RTL
Text direction is forced to RTL. |
String |
VIEW_LOG_TAG
The logging tag used by this class with android.util.Log. |
int |
VISIBLE
This view is visible. |
Fields | |
---|---|
public
static
final
Property<View, Float> |
ALPHA
A Property wrapper around the |
protected
static
final
int[] |
EMPTY_STATE_SET
Indicates the view has no states set. |
protected
static
final
int[] |
ENABLED_FOCUSED_SELECTED_STATE_SET
Indicates the view is enabled, focused and selected. |
protected
static
final
int[] |
ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET
Indicates the view is enabled, focused, selected and its window has the focus. |
protected
static
final
int[] |
ENABLED_FOCUSED_STATE_SET
Indicates the view is enabled and has the focus. |
protected
static
final
int[] |
ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET
Indicates the view is enabled, focused and its window has the focus. |
protected
static
final
int[] |
ENABLED_SELECTED_STATE_SET
Indicates the view is enabled and selected. |
protected
static
final
int[] |
ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET
Indicates the view is enabled, selected and its window has the focus. |
protected
static
final
int[] |
ENABLED_STATE_SET
Indicates the view is enabled. |
protected
static
final
int[] |
ENABLED_WINDOW_FOCUSED_STATE_SET
Indicates the view is enabled and that its window has focus. |
protected
static
final
int[] |
FOCUSED_SELECTED_STATE_SET
Indicates the view is focused and selected. |
protected
static
final
int[] |
FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET
Indicates the view is focused, selected and its window has the focus. |
protected
static
final
int[] |
FOCUSED_STATE_SET
Indicates the view is focused. |
protected
static
final
int[] |
FOCUSED_WINDOW_FOCUSED_STATE_SET
Indicates the view has the focus and that its window has the focus. |
protected
static
final
int[] |
PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET
Indicates the view is pressed, enabled, focused and selected. |
protected
static
final
int[] |
PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET
Indicates the view is pressed, enabled, focused, selected and its window has the focus. |
protected
static
final
int[] |
PRESSED_ENABLED_FOCUSED_STATE_SET
Indicates the view is pressed, enabled and focused. |
protected
static
final
int[] |
PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET
Indicates the view is pressed, enabled, focused and its window has the focus. |
protected
static
final
int[] |
PRESSED_ENABLED_SELECTED_STATE_SET
Indicates the view is pressed, enabled and selected. |
protected
static
final
int[] |
PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET
Indicates the view is pressed, enabled, selected and its window has the focus. |
protected
static
final
int[] |
PRESSED_ENABLED_STATE_SET
Indicates the view is pressed and enabled. |
protected
static
final
int[] |
PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET
Indicates the view is pressed, enabled and its window has the focus. |
protected
static
final
int[] |
PRESSED_FOCUSED_SELECTED_STATE_SET
Indicates the view is pressed, focused and selected. |
protected
static
final
int[] |
PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET
Indicates the view is pressed, focused, selected and its window has the focus. |
protected
static
final
int[] |
PRESSED_FOCUSED_STATE_SET
Indicates the view is pressed and focused. |
protected
static
final
int[] |
PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET
Indicates the view is pressed, focused and its window has the focus. |
protected
static
final
int[] |
PRESSED_SELECTED_STATE_SET
Indicates the view is pressed and selected. |
protected
static
final
int[] |
PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET
Indicates the view is pressed, selected and its window has the focus. |
protected
static
final
int[] |
PRESSED_STATE_SET
Indicates the view is pressed. |
protected
static
final
int[] |
PRESSED_WINDOW_FOCUSED_STATE_SET
Indicates the view is pressed and its window has the focus. |
public
static
final
Property<View, Float> |
ROTATION
A Property wrapper around the |
public
static
final
Property<View, Float> |
ROTATION_X
A Property wrapper around the |
public
static
final
Property<View, Float> |
ROTATION_Y
A Property wrapper around the |
public
static
final
Property<View, Float> |
SCALE_X
A Property wrapper around the |
public
static
final
Property<View, Float> |
SCALE_Y
A Property wrapper around the |
protected
static
final
int[] |
SELECTED_STATE_SET
Indicates the view is selected. |
protected
static
final
int[] |
SELECTED_WINDOW_FOCUSED_STATE_SET
Indicates the view is selected and that its window has the focus. |
public
static
final
Property<View, Float> |
TRANSLATION_X
A Property wrapper around the |
public
static
final
Property<View, Float> |
TRANSLATION_Y
A Property wrapper around the |
public
static
final
Property<View, Float> |
TRANSLATION_Z
A Property wrapper around the |
protected
static
final
int[] |
WINDOW_FOCUSED_STATE_SET
Indicates the view's window has focus. |
public
static
final
Property<View, Float> |
X
A Property wrapper around the |
public
static
final
Property<View, Float> |
Y
A Property wrapper around the |
public
static
final
Property<View, Float> |
Z
A Property wrapper around the |
Public constructors | |
---|---|
View(Context context)
Simple constructor to use when creating a view from code. |
|
View(Context context, AttributeSet attrs)
Constructor that is called when inflating a view from XML. |
|
View(Context context, AttributeSet attrs, int defStyleAttr)
Perform inflation from XML and apply a class-specific base style from a theme attribute. |
|
View(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
Perform inflation from XML and apply a class-specific base style from a theme attribute or style resource. |
Public methods | |
---|---|
void
|
addChildrenForAccessibility(ArrayList<View> outChildren)
Adds the children of this View relevant for accessibility to the given list as output. |
void
|
addExtraDataToAccessibilityNodeInfo(AccessibilityNodeInfo info, String extraDataKey, Bundle arguments)
Adds extra data to an |
void
|
addFocusables(ArrayList<View> views, int direction)
Add any focusable views that are descendants of this view (possibly including this view if it is focusable itself) to views. |
void
|
addFocusables(ArrayList<View> views, int direction, int focusableMode)
Adds any focusable views that are descendants of this view (possibly including this view if it is focusable itself) to views. |
void
|
addKeyboardNavigationClusters(Collection<View> views, int direction)
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. |
void
|
addOnAttachStateChangeListener(View.OnAttachStateChangeListener listener)
Add a listener for attach state changes. |
void
|
addOnLayoutChangeListener(View.OnLayoutChangeListener listener)
Add a listener that will be called when the bounds of the view change due to layout processing. |
void
|
addOnUnhandledKeyEventListener(View.OnUnhandledKeyEventListener listener)
Adds a listener which will receive unhandled |
void
|
addTouchables(ArrayList<View> views)
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. |
void
|
announceForAccessibility(CharSequence text)
This method was deprecated in API level 36. Use one of the methods described in the documentation above to semantically describe UI instead of using an announcement, as accessibility services may choose to ignore events dispatched with this method. |
void
|
autofill(AutofillValue value)
Automatically fills the content of this view with the |
void
|
autofill(SparseArray<AutofillValue> values)
Automatically fills the content of the virtual children within this view. |
void
|
bringToFront()
Change the view's z order in the tree, so it's on top of other sibling views. |
void
|
buildDrawingCache(boolean autoScale)
This method was deprecated
in API level 28.
The view drawing cache was largely made obsolete with the introduction of
hardware-accelerated rendering in API 11. With hardware-acceleration, intermediate cache
layers are largely unnecessary and can easily result in a net loss in performance due to the
cost of creating and updating the layer. In the rare cases where caching layers are useful,
such as for alpha animations, |
void
|
buildDrawingCache()
This method was deprecated
in API level 28.
The view drawing cache was largely made obsolete with the introduction of
hardware-accelerated rendering in API 11. With hardware-acceleration, intermediate cache
layers are largely unnecessary and can easily result in a net loss in performance due to the
cost of creating and updating the layer. In the rare cases where caching layers are useful,
such as for alpha animations, |
void
|
buildLayer()
Forces this view's layer to be created and this view to be rendered into its layer. |
boolean
|
callOnClick()
Directly call any attached OnClickListener. |
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(int direction)
Check if this view can be scrolled horizontally in a certain direction. |
boolean
|
canScrollVertically(int direction)
Check if this view can be scrolled vertically in a certain direction. |
final
void
|
cancelDragAndDrop()
Cancels an ongoing drag and drop operation. |
void
|
cancelLongPress()
Cancels a pending long press. |
final
void
|
cancelPendingInputEvents()
Cancel any deferred high-level input events that were previously posted to the event queue. |
boolean
|
checkInputConnectionProxy(View view)
Called by the |
void
|
clearAnimation()
Cancels any animations for this view. |
void
|
clearFocus()
Called when this view wants to give up focus. |
void
|
clearPendingCredentialRequest()
Clears the request and callback previously set
through |
void
|
clearViewTranslationCallback()
Clear the |
static
int
|
combineMeasuredStates(int curState, int newState)
Merge two states as returned by |
void
|
computeScroll()
Called by a parent to request that a child update its values for mScrollX and mScrollY if necessary. |
WindowInsets
|
computeSystemWindowInsets(WindowInsets in, Rect outLocalInsets)
Compute insets that should be consumed by this view and the ones that should propagate to those under it. |
AccessibilityNodeInfo
|
createAccessibilityNodeInfo()
Returns an |
void
|
createContextMenu(ContextMenu menu)
Show the context menu for this view. |
void
|
destroyDrawingCache()
This method was deprecated
in API level 28.
The view drawing cache was largely made obsolete with the introduction of
hardware-accelerated rendering in API 11. With hardware-acceleration, intermediate cache
layers are largely unnecessary and can easily result in a net loss in performance due to the
cost of creating and updating the layer. In the rare cases where caching layers are useful,
such as for alpha animations, |
WindowInsets
|
dispatchApplyWindowInsets(WindowInsets insets)
Request to apply the given window insets to this view or another view in its subtree. |
boolean
|
dispatchCapturedPointerEvent(MotionEvent event)
Pass a captured pointer event down to the focused view. |
void
|
dispatchConfigurationChanged(Configuration newConfig)
Dispatch a notification about a resource configuration change down the view hierarchy. |
void
|
dispatchCreateViewTranslationRequest(Map<AutofillId, long[]> viewIds, int[] supportedFormats, TranslationCapability capability, List<ViewTranslationRequest> requests)
Dispatch to collect the |
void
|
dispatchDisplayHint(int hint)
Dispatch a hint about whether this view is displayed. |
boolean
|
dispatchDragEvent(DragEvent event)
Detects if this View is enabled and has a drag event listener. |
void
|
dispatchDrawableHotspotChanged(float x, float y)
Dispatches drawableHotspotChanged to all of this View's children. |
void
|
dispatchFinishTemporaryDetach()
Dispatch |
boolean
|
dispatchGenericMotionEvent(MotionEvent event)
Dispatch a generic motion event. |
boolean
|
dispatchKeyEvent(KeyEvent event)
Dispatch a key event to the next view on the focus path. |
boolean
|
dispatchKeyEventPreIme(KeyEvent event)
Dispatch a key event before it is processed by any input method associated with the view hierarchy. |
boolean
|
dispatchKeyShortcutEvent(KeyEvent event)
Dispatches a key shortcut event. |
boolean
|
dispatchNestedFling(float velocityX, float velocityY, boolean consumed)
Dispatch a fling to a nested scrolling parent. |
boolean
|
dispatchNestedPreFling(float velocityX, float velocityY)
Dispatch a fling to a nested scrolling parent before it is processed by this view. |
boolean
|
dispatchNestedPrePerformAccessibilityAction(int action, Bundle arguments)
Report an accessibility action to this view's parents for delegated processing. |
boolean
|
dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow)
Dispatch one step of a nested scroll in progress before this view consumes any portion of it. |
boolean
|
dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow)
Dispatch one step of a nested scroll in progress. |
void
|
dispatchPointerCaptureChanged(boolean hasCapture)
|
boolean
|
dispatchPopulateAccessibilityEvent(AccessibilityEvent event)
Dispatches an |
void
|
dispatchProvideAutofillStructure(ViewStructure structure, int flags)
Dispatches creation of a |
void
|
dispatchProvideStructure(ViewStructure structure)
Dispatch creation of |
void
|
dispatchScrollCaptureSearch(Rect localVisibleRect, Point windowOffset, Consumer<ScrollCaptureTarget> targets)
Dispatch a scroll capture search request down the view hierarchy. |
void
|
dispatchStartTemporaryDetach()
Dispatch |
void
|
dispatchSystemUiVisibilityChanged(int visibility)
This method was deprecated
in API level 30.
Use |
boolean
|
dispatchTouchEvent(MotionEvent event)
Pass the touch screen motion event down to the target view, or this view if it is the target. |
boolean
|
dispatchTrackballEvent(MotionEvent event)
Pass a trackball motion event down to the focused view. |
boolean
|
dispatchUnhandledMove(View focused, int direction)
This method is the last chance for the focused view and its ancestors to respond to an arrow key. |
void
|
dispatchWindowFocusChanged(boolean hasFocus)
Called when the window containing this view gains or loses window focus. |
void
|
dispatchWindowInsetsAnimationEnd(WindowInsetsAnimation animation)
Dispatches |
void
|
dispatchWindowInsetsAnimationPrepare(WindowInsetsAnimation animation)
Dispatches |
WindowInsets
|
dispatchWindowInsetsAnimationProgress(WindowInsets insets, List<WindowInsetsAnimation> runningAnimations)
Dispatches |
WindowInsetsAnimation.Bounds
|
dispatchWindowInsetsAnimationStart(WindowInsetsAnimation animation, WindowInsetsAnimation.Bounds bounds)
Dispatches |
void
|
dispatchWindowSystemUiVisiblityChanged(int visible)
This method was deprecated
in API level 30.
SystemUiVisibility flags are deprecated. Use |
void
|
dispatchWindowVisibilityChanged(int visibility)
Dispatch a window visibility change down the view hierarchy. |
void
|
draw(Canvas canvas)
Manually render this view (and all of its children) to the given Canvas. |
void
|
drawableHotspotChanged(float x, float y)
This function is called whenever the view hotspot changes and needs to be propagated to drawables or child views managed by the view. |
View
|
findFocus()
Find the view in the hierarchy rooted at this view that currently has focus. |
final
OnBackInvokedDispatcher
|
findOnBackInvokedDispatcher()
Walk up the View hierarchy to find the nearest |
final
<T extends View>
T
|
findViewById(int id)
Finds the first descendant view with the given ID, the view itself if
the ID matches |
final
<T extends View>
T
|
findViewWithTag(Object tag)
Look for a child view with the given tag. |
void
|
findViewsWithText(ArrayList<View> outViews, CharSequence searched, int flags)
Finds the Views that contain given text. |
View
|
focusSearch(int direction)
Find the nearest view in the specified direction that can take focus. |
void
|
forceHasOverlappingRendering(boolean hasOverlappingRendering)
Sets the behavior for overlapping rendering for this view (see |
void
|
forceLayout()
Forces this view to be laid out during the next layout pass. |
boolean
|
gatherTransparentRegion(Region region)
This is used by the ViewRoot to perform an optimization when the view hierarchy contains one or several SurfaceView. |
void
|
generateDisplayHash(String hashAlgorithm, Rect bounds, Executor executor, DisplayHashResultCallback callback)
Called to generate a |
static
int
|
generateViewId()
Generate a value suitable for use in |
CharSequence
|
getAccessibilityClassName()
Return the class name of this object to be used for accessibility purposes. |
View.AccessibilityDelegate
|
getAccessibilityDelegate()
Returns the delegate for implementing accessibility support via composition. |
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 |
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 |
String
|
getAllowedHandwritingDelegatorPackageName()
Returns the allowed package for views which may act as a handwriting delegator for this
delegate editor view, as set by |
float
|
getAlpha()
The opacity of the view. |
Animation
|
getAnimation()
Get the animation currently associated with this view. |
Matrix
|
getAnimationMatrix()
Return the current transformation matrix of the view. |
IBinder
|
getApplicationWindowToken()
Retrieve a unique token identifying the top-level "real" window of the window that this view is attached to. |
int[]
|
getAttributeResolutionStack(int attribute)
Returns the ordered list of resource ID that are considered when resolving attribute values
for this |
Map<Integer, Integer>
|
getAttributeSourceResourceMap()
Returns the mapping of attribute resource ID to source resource ID where the attribute value was set. |
String[]
|
getAutofillHints()
Gets the hints that help an |
final
AutofillId
|
getAutofillId()
Gets the unique, logical identifier of this view in the activity, for autofill purposes. |
int
|
getAutofillType()
Describes the autofill type of this view, so an
|
AutofillValue
|
getAutofillValue()
Gets the |
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
|
getBaseline()
Return the offset of the widget's text baseline from the widget's top boundary. |
final
int
|
getBottom()
Bottom position of this view relative to its parent. |
float
|
getCameraDistance()
Gets the distance along the Z axis from the camera to this view. |
boolean
|
getClipBounds(Rect outRect)
Populates an output rectangle with the clip bounds of the view,
returning |
Rect
|
getClipBounds()
Returns a copy of the current |
final
boolean
|
getClipToOutline()
Returns whether the Outline should be used to clip the contents of the View. |
final
ContentCaptureSession
|
getContentCaptureSession()
Gets the session used to notify content capture events. |
CharSequence
|
getContentDescription()
Returns the |
final
int
|
getContentSensitivity()
Gets content sensitivity mode to determine whether this view displays sensitive content. |
final
Context
|
getContext()
Returns the context the view is running in, through which it can access the current theme, resources, etc. |
final
boolean
|
getDefaultFocusHighlightEnabled()
Returns whether this View should use a default focus highlight when it gets focused but
doesn't have |
static
int
|
getDefaultSize(int size, int measureSpec)
Utility to return a default size. |
Display
|
getDisplay()
Gets the logical display to which the view's window has been attached. |
final
int[]
|
getDrawableState()
Return an array of resource IDs of the drawable states representing the current state of the view. |
Bitmap
|
getDrawingCache()
This method was deprecated
in API level 28.
The view drawing cache was largely made obsolete with the introduction of
hardware-accelerated rendering in API 11. With hardware-acceleration, intermediate cache
layers are largely unnecessary and can easily result in a net loss in performance due to the
cost of creating and updating the layer. In the rare cases where caching layers are useful,
such as for alpha animations, |
Bitmap
|
getDrawingCache(boolean autoScale)
This method was deprecated
in API level 28.
The view drawing cache was largely made obsolete with the introduction of
hardware-accelerated rendering in API 11. With hardware-acceleration, intermediate cache
layers are largely unnecessary and can easily result in a net loss in performance due to the
cost of creating and updating the layer. In the rare cases where caching layers are useful,
such as for alpha animations, |
int
|
getDrawingCacheBackgroundColor()
This method was deprecated
in API level 28.
The view drawing cache was largely made obsolete with the introduction of
hardware-accelerated rendering in API 11. With hardware-acceleration, intermediate cache
layers are largely unnecessary and can easily result in a net loss in performance due to the
cost of creating and updating the layer. In the rare cases where caching layers are useful,
such as for alpha animations, |
int
|
getDrawingCacheQuality()
This method was deprecated
in API level 28.
The view drawing cache was largely made obsolete with the introduction of
hardware-accelerated rendering in API 11. With hardware-acceleration, intermediate cache
layers are largely unnecessary and can easily result in a net loss in performance due to the
cost of creating and updating the layer. In the rare cases where caching layers are useful,
such as for alpha animations, |
void
|
getDrawingRect(Rect outRect)
Return the visible drawing bounds of your view. |
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 |
boolean
|
getFilterTouchesWhenObscured()
Gets whether the framework should discard touches when the view's window is obscured by another visible window at the touched location. |
boolean
|
getFitsSystemWindows()
Check for state of |
int
|
getFocusable()
Returns the focusable setting for this view. |
ArrayList<View>
|
getFocusables(int direction)
Find and return all focusable views that are descendants of this view, possibly including this view if it is focusable itself. |
void
|
getFocusedRect(Rect r)
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. |
Drawable
|
getForeground()
Returns the drawable used as the foreground of this View. |
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. |
final
boolean
|
getGlobalVisibleRect(Rect r)
Sets |
boolean
|
getGlobalVisibleRect(Rect r, Point globalOffset)
Sets |
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 |
Runnable
|
getHandwritingDelegatorCallback()
Returns the callback set by |
final
boolean
|
getHasOverlappingRendering()
Returns the value for overlapping rendering that is used internally. |
final
int
|
getHeight()
Return the height of your view. |
void
|
getHitRect(Rect outRect)
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. |
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. |
int
|
getImportantForAutofill()
Gets the mode for determining whether this view is important for autofill. |
int
|
getImportantForContentCapture()
Gets the mode for determining whether this view is important for content capture. |
boolean
|
getKeepScreenOn()
Returns whether the screen should remain on, corresponding to the current
value of |
KeyEvent.DispatcherState
|
getKeyDispatcherState()
Return the global |
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. |
int
|
getLayoutDirection()
Returns the resolved layout direction for this view. |
ViewGroup.LayoutParams
|
getLayoutParams()
Get the LayoutParams associated with this view. |
final
int
|
getLeft()
Left position of this view relative to its parent. |
final
boolean
|
getLocalVisibleRect(Rect r)
Sets |
void
|
getLocationInSurface(int[] location)
Gets the coordinates of this view in the coordinate space of the
|
void
|
getLocationInWindow(int[] outLocation)
Gets the coordinates of this view in the coordinate space of the window that contains the view, irrespective of system decorations. |
void
|
getLocationOnScreen(int[] outLocation)
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. |
Matrix
|
getMatrix()
The transform matrix of this view, which is calculated based on the current rotation, scale, and pivot properties. |
final
int
|
getMeasuredHeight()
Like |
final
int
|
getMeasuredHeightAndState()
Return the full height measurement information for this view as computed
by the most recent call to |
final
int
|
getMeasuredState()
Return only the state bits of |
final
int
|
getMeasuredWidth()
Like |
final
int
|
getMeasuredWidthAndState()
Return the full width measurement information for this view as computed
by the most recent call to |
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 |
int
|
getNextFocusForwardId()
Gets the id of the view to use when the next focus is |
int
|
getNextFocusLeftId()
Gets the id of the view to use when the next focus is |
int
|
getNextFocusRightId()
Gets the id of the view to use when the next focus is |
int
|
getNextFocusUpId()
Gets the id of the view to use when the next focus is |
View.OnFocusChangeListener
|
getOnFocusChangeListener()
Returns the focus-change callback registered for this view. |
int
|
getOutlineAmbientShadowColor()
|
ViewOutlineProvider
|
getOutlineProvider()
Returns the current |
int
|
getOutlineSpotShadowColor()
|
int
|
getOverScrollMode()
Returns the over-scroll mode for this view. |
ViewOverlay
|
getOverlay()
Returns the overlay for this view, creating it if it does not yet exist. |
int
|
getPaddingBottom()
Returns the bottom padding of this view. |
int
|
getPaddingEnd()
Returns the end padding of this view depending on its resolved layout direction. |
int
|
getPaddingLeft()
Returns the left padding of this view. |
int
|
getPaddingRight()
Returns the right padding of this view. |
int
|
getPaddingStart()
Returns the start padding of this view depending on its resolved layout direction. |
int
|
getPaddingTop()
Returns the top padding of this view. |
final
ViewParent
|
getParent()
Gets the parent of this view. |
ViewParent
|
getParentForAccessibility()
Gets the parent for accessibility purposes. |
final
OutcomeReceiver<GetCredentialResponse, GetCredentialException>
|
getPendingCredentialCallback()
Returns the callback that has previously been set up on this view through
the |
final
GetCredentialRequest
|
getPendingCredentialRequest()
Returns the |
float
|
getPivotX()
The x location of the point around which the view is |
float
|
getPivotY()
The y location of the point around which the view is |
PointerIcon
|
getPointerIcon()
Gets the mouse pointer icon for the current view. |
final
List<Rect>
|
getPreferKeepClearRects()
|
String[]
|
getReceiveContentMimeTypes()
Returns the MIME types accepted by |
float
|
getRequestedFrameRate()
Get the current preferred frame rate of the View. |
Resources
|
getResources()
Returns the resources associated with this view. |
final
boolean
|
getRevealOnFocusHint()
Returns this view's preference for reveal behavior when it gains focus. |
final
int
|
getRight()
Right position of this view relative to its parent. |
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. |
View
|
getRootView()
Finds the topmost view in the current view hierarchy. |
WindowInsets
|
getRootWindowInsets()
Provide original WindowInsets that are dispatched to the view hierarchy. |
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. |
float
|
getScaleY()
The amount that the view is scaled in y around the pivot point, as a proportion of the view's unscaled height. |
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. |
final
int
|
getScrollX()
Return the scrolled left position of this view. |
final
int
|
getScrollY()
Return the scrolled top position of this view. |
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. |
int
|
getSourceLayoutResId()
A |
final
CharSequence
|
getStateDescription()
Returns the |
StateListAnimator
|
getStateListAnimator()
Returns the current StateListAnimator if exists. |
CharSequence
|
getSupplementalDescription()
Returns the |
List<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. |
int
|
getSystemUiVisibility()
This method was deprecated
in API level 30.
SystemUiVisibility flags are deprecated. Use |
Object
|
getTag()
Returns this view's tag. |
Object
|
getTag(int key)
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. |
final
int
|
getTop()
Top position of this view relative to its parent. |
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. |
String
|
getTransitionName()
Returns the name of the View to be used to identify Views in Transitions. |
float
|
getTranslationX()
The horizontal location of this view relative to its |
float
|
getTranslationY()
The vertical location of this view relative to its |
float
|
getTranslationZ()
The depth location of this view relative to its |
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 |
ViewTreeObserver
|
getViewTreeObserver()
Returns the ViewTreeObserver for this view's hierarchy. |
int
|
getVisibility()
Returns the visibility status for this view. |
final
int
|
getWidth()
Return the width of your view. |
WindowId
|
getWindowId()
Retrieve the |
WindowInsetsController
|
getWindowInsetsController()
Retrieves the single |
int
|
getWindowSystemUiVisibility()
This method was deprecated
in API level 30.
SystemUiVisibility flags are deprecated. Use |
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 |
void
|
getWindowVisibleDisplayFrame(Rect outRect)
Retrieve the overall visible display size in which the window this view is attached to has been positioned in. |
float
|
getX()
The visual x position of this view, in pixels. |
float
|
getY()
The visual y position of this view, in pixels. |
float
|
getZ()
The visual z position of this view, in pixels. |
boolean
|
hasExplicitFocusable()
Returns true if this view is focusable or if it contains a reachable View
for which |
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 |
boolean
|
hasNestedScrollingParent()
Returns true if this view has a nested scrolling parent. |
boolean
|
hasOnClickListeners()
Return whether this view has an attached OnClickListener. |
boolean
|
hasOnLongClickListeners()
Return whether this view has an attached OnLongClickListener. |
boolean
|
hasOverlappingRendering()
Returns whether this View has content which overlaps. |
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. |
boolean
|
hasWindowFocus()
Returns true if this view is in a window that currently has window focus. |
static
View
|
inflate(Context context, int resource, ViewGroup root)
Inflate a view from an XML resource. |
void
|
invalidate()
Invalidate the whole view. |
void
|
invalidate(Rect dirty)
This method was deprecated
in API level 28.
The switch to hardware accelerated rendering in API 14 reduced
the importance of the dirty rectangle. In API 21 the given rectangle is
ignored entirely in favor of an internally-calculated area instead.
Because of this, clients are encouraged to just call |
void
|
invalidate(int l, int t, int r, int b)
This method was deprecated
in API level 28.
The switch to hardware accelerated rendering in API 14 reduced
the importance of the dirty rectangle. In API 21 the given rectangle is
ignored entirely in favor of an internally-calculated area instead.
Because of this, clients are encouraged to just call |
void
|
invalidateDrawable(Drawable drawable)
Invalidates the specified Drawable. |
void
|
invalidateOutline()
Called to rebuild this View's Outline from its |
boolean
|
isAccessibilityDataSensitive()
Whether this view should restrict accessibility service access only to services that have the
|
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. |
boolean
|
isClickable()
Indicates whether this view reacts to click events or not. |
final
boolean
|
isContentSensitive()
Returns whether this view displays sensitive content, based
on the value explicitly set by |
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. |
boolean
|
isDirty()
True if this view has changed since the last time being drawn. |
boolean
|
isDrawingCacheEnabled()
This method was deprecated
in API level 28.
The view drawing cache was largely made obsolete with the introduction of
hardware-accelerated rendering in API 11. With hardware-acceleration, intermediate cache
layers are largely unnecessary and can easily result in a net loss in performance due to the
cost of creating and updating the layer. In the rare cases where caching layers are useful,
such as for alpha animations, |
boolean
|
isDuplicateParentStateEnabled()
Indicates whether this duplicates its drawable state from its parent. |
boolean
|
isEnabled()
Returns the enabled status for this view. |
final
boolean
|
isFocusable()
Returns whether this View is currently able to take focus. |
final
boolean
|
isFocusableInTouchMode()
When a view is focusable, it may not want to take focus when in touch mode. |
boolean
|
isFocused()
Returns true if this view has focus |
final
boolean
|
isFocusedByDefault()
Returns whether this View should receive focus when the focus is restored for the view hierarchy containing this view. |
boolean
|
isForceDarkAllowed()
|
boolean
|
isHandwritingDelegate()
Returns whether this view has been set as a handwriting delegate by |
boolean
|
isHapticFeedbackEnabled()
|
boolean
|
isHardwareAccelerated()
Indicates whether this view is attached to a hardware accelerated window or not. |
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. |
boolean
|
isHovered()
Returns true if the view is currently hovered. |
boolean
|
isImportantForAccessibility()
Computes whether this view should be exposed for accessibility. |
final
boolean
|
isImportantForAutofill()
Hints the Android System whether the |
final
boolean
|
isImportantForContentCapture()
Hints the Android System whether this view is considered important for content capture, based
on the value explicitly set by |
boolean
|
isInEditMode()
Indicates whether this View is currently in edit mode. |
boolean
|
isInLayout()
Returns whether the view hierarchy is currently undergoing a layout pass. |
boolean
|
isInTouchMode()
Returns the touch mode state associated with this view. |
final
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. |
boolean
|
isOpaque()
Indicates whether this View is opaque. |
boolean
|
isPaddingRelative()
Return if the padding has been set through relative values
|
boolean
|
isPivotSet()
Returns whether or not a pivot has been set by a call to |
final
boolean
|
isPreferKeepClear()
Retrieve the preference for this view to be kept clear. |
boolean
|
isPressed()
Indicates whether the view is currently in pressed state. |
boolean
|
isSaveEnabled()
Indicates whether this view will save its state (that is,
whether its |
boolean
|
isSaveFromParentEnabled()
Indicates whether the entire hierarchy under this view will save its state when a state saving traversal occurs from its parent. |
boolean
|
isScreenReaderFocusable()
Returns whether the view should be treated as a focusable unit by screen reader accessibility tools. |
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. |
final
boolean
|
isShowingLayoutBounds()
Returns |
boolean
|
isShown()
Returns the visibility of this view and all of its ancestors |
boolean
|
isSoundEffectsEnabled()
|
final
boolean
|
isTemporarilyDetached()
Tells whether the |
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. |
boolean
|
isVisibleToUserForAutofill(int virtualId)
Computes whether this virtual autofill view is visible to the user. |
void
|
jumpDrawablesToCurrentState()
Call |
View
|
keyboardNavigationClusterSearch(View currentCluster, int direction)
Find the nearest keyboard navigation cluster in the specified direction. |
void
|
layout(int l, int t, int r, int b)
Assign a size and position to a view and all of its descendants This is the second phase of the layout mechanism. |
final
void
|
measure(int widthMeasureSpec, int heightMeasureSpec)
This is called to find out how big a view should be. |
void
|
offsetLeftAndRight(int offset)
Offset this view's horizontal location by the specified amount of pixels. |
void
|
offsetTopAndBottom(int offset)
Offset this view's vertical location by the specified number of pixels. |
WindowInsets
|
onApplyWindowInsets(WindowInsets insets)
Called when the view should apply |
void
|
onCancelPendingInputEvents()
Called as the result of a call to |
boolean
|
onCapturedPointerEvent(MotionEvent event)
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. |
InputConnection
|
onCreateInputConnection(EditorInfo outAttrs)
Create a new InputConnection for an InputMethod to interact with the view. |
void
|
onCreateViewTranslationRequest(int[] supportedFormats, Consumer<ViewTranslationRequest> requestsCollector)
Collects a |
void
|
onCreateVirtualViewTranslationRequests(long[] virtualIds, int[] supportedFormats, Consumer<ViewTranslationRequest> requestsCollector)
Collects |
boolean
|
onDragEvent(DragEvent event)
Handles drag events sent by the system following a call to
|
void
|
onDrawForeground(Canvas canvas)
Draw any foreground content for this view. |
boolean
|
onFilterTouchEventForSecurity(MotionEvent event)
Filter the touch event to apply security policies. |
void
|
onFinishTemporaryDetach()
Called after |
boolean
|
onGenericMotionEvent(MotionEvent event)
Implement this method to handle generic motion events. |
void
|
onHoverChanged(boolean hovered)
Implement this method to handle hover state changes. |
boolean
|
onHoverEvent(MotionEvent event)
Implement this method to handle hover events. |
void
|
onInitializeAccessibilityEvent(AccessibilityEvent event)
Initializes an |
void
|
onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)
Initializes an |
boolean
|
onKeyDown(int keyCode, KeyEvent event)
Default implementation of |
boolean
|
onKeyLongPress(int keyCode, KeyEvent event)
Default implementation of |
boolean
|
onKeyMultiple(int keyCode, int repeatCount, KeyEvent event)
Default implementation of |
boolean
|
onKeyPreIme(int keyCode, KeyEvent event)
Handle a key event before it is processed by any input method associated with the view hierarchy. |
boolean
|
onKeyShortcut(int keyCode, KeyEvent event)
Called on the focused view when a key shortcut event is not handled. |
boolean
|
onKeyUp(int keyCode, KeyEvent event)
Default implementation of |
void
|
onPointerCaptureChange(boolean hasCapture)
Called when the window has just acquired or lost pointer capture. |
void
|
onPopulateAccessibilityEvent(AccessibilityEvent event)
Called from |
void
|
onProvideAutofillStructure(ViewStructure structure, int flags)
Populates a |
void
|
onProvideAutofillVirtualStructure(ViewStructure structure, int flags)
Populates a |
void
|
onProvideContentCaptureStructure(ViewStructure structure, int flags)
Populates a |
void
|
onProvideStructure(ViewStructure structure)
Called when assist structure is being retrieved from a view as part of
|
void
|
onProvideVirtualStructure(ViewStructure structure)
Called when assist structure is being retrieved from a view as part of
|
ContentInfo
|
onReceiveContent(ContentInfo payload)
Implements the default behavior for receiving content for this type of view. |
PointerIcon
|
onResolvePointerIcon(MotionEvent event, int pointerIndex)
Resolve the pointer icon that should be used for specified pointer in the motion event. |
void
|
onRtlPropertiesChanged(int layoutDirection)
Called when any RTL property (layout direction or text direction or text alignment) has been changed. |
void
|
onScreenStateChanged(int screenState)
This method is called whenever the state of the screen this view is attached to changes. |
void
|
onScrollCaptureSearch(Rect localVisibleRect, Point windowOffset, Consumer<ScrollCaptureTarget> targets)
Called when scroll capture is requested, to search for appropriate content to scroll. |
void
|
onStartTemporaryDetach()
This is called when a container is going to temporarily detach a child, with
|
boolean
|
onTouchEvent(MotionEvent event)
Implement this method to handle pointer events. |
boolean
|
onTrackballEvent(MotionEvent event)
Implement this method to handle trackball motion events. |
void
|
onViewTranslationResponse(ViewTranslationResponse response)
Called when the content from |
void
|
onVirtualViewTranslationResponses(LongSparseArray<ViewTranslationResponse> response)
Called when the content from |
void
|
onVisibilityAggregated(boolean isVisible)
Called when the user-visibility of this View is potentially affected by a change to this view itself, an ancestor view or the window this view is attached to. |
void
|
onWindowFocusChanged(boolean hasWindowFocus)
Called when the window containing this view gains or loses focus. |
void
|
onWindowSystemUiVisibilityChanged(int visible)
This method was deprecated
in API level 30.
SystemUiVisibility flags are deprecated. Use |
boolean
|
performAccessibilityAction(int action, Bundle arguments)
Performs the specified accessibility action on the view. |
boolean
|
performClick()
Call this view's OnClickListener, if it is defined. |
boolean
|
performContextClick(float x, float y)
Call this view's OnContextClickListener, if it is defined. |
boolean
|
performContextClick()
Call this view's OnContextClickListener, if it is defined. |
boolean
|
performHapticFeedback(int feedbackConstant)
BZZZTT!!1! Provide haptic feedback to the user for this view. |
boolean
|
performHapticFeedback(HapticFeedbackRequest request)
Like |
boolean
|
performHapticFeedback(int feedbackConstant, int flags)
BZZZTT!!1! Like |
boolean
|
performLongClick(float x, float y)
Calls this view's OnLongClickListener, if it is defined. |
boolean
|
performLongClick()
Calls this view's OnLongClickListener, if it is defined. |
ContentInfo
|
performReceiveContent(ContentInfo payload)
Receives the given content. |
void
|
playSoundEffect(int soundConstant)
Play a sound effect for this view. |
boolean
|
post(Runnable action)
Causes the Runnable to be added to the message queue. |
boolean
|
postDelayed(Runnable action, long delayMillis)
Causes the Runnable to be added to the message queue, to be run after the specified amount of time elapses. |
void
|
postInvalidate()
Cause an invalidate to happen on a subsequent cycle through the event loop. |
void
|
postInvalidate(int left, int top, int right, int bottom)
Cause an invalidate of the specified area to happen on a subsequent cycle through the event loop. |
void
|
postInvalidateDelayed(long delayMilliseconds, int left, int top, int right, int bottom)
Cause an invalidate of the specified area to happen on a subsequent cycle through the event loop. |
void
|
postInvalidateDelayed(long delayMilliseconds)
Cause an invalidate to happen on a subsequent cycle through the event loop. |
void
|
postInvalidateOnAnimation(int left, int top, int right, int bottom)
Cause an invalidate of the specified area to happen on the next animation time step, typically the next display frame. |
void
|
postInvalidateOnAnimation()
Cause an invalidate to happen on the next animation time step, typically the next display frame. |
void
|
postOnAnimation(Runnable action)
Causes the Runnable to execute on the next animation time step. |
void
|
postOnAnimationDelayed(Runnable action, long delayMillis)
Causes the Runnable to execute on the next animation time step, after the specified amount of time elapses. |
void
|
refreshDrawableState()
Call this to force a view to update its drawable state. |
void
|
releasePointerCapture()
Releases the pointer capture. |
boolean
|
removeCallbacks(Runnable action)
Removes the specified Runnable from the message queue. |
void
|
removeOnAttachStateChangeListener(View.OnAttachStateChangeListener listener)
Remove a listener for attach state changes. |
void
|
removeOnLayoutChangeListener(View.OnLayoutChangeListener listener)
Remove a listener for layout changes. |
void
|
removeOnUnhandledKeyEventListener(View.OnUnhandledKeyEventListener listener)
Removes a listener which will receive unhandled |
void
|
reportAppJankStats(AppJankStats appJankStats)
Called from apps when they want to report jank stats to the system. |
void
|
requestApplyInsets()
Ask that a new dispatch of |
void
|
requestFitSystemWindows()
This method was deprecated
in API level 20.
Use |
final
boolean
|
requestFocus(int direction)
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. |
final
boolean
|
requestFocus()
Call this to try to give focus to a specific view or to one of its descendants. |
boolean
|
requestFocus(int direction, Rect previouslyFocusedRect)
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. |
final
boolean
|
requestFocusFromTouch()
Call this to try to give focus to a specific view or to one of its descendants. |
void
|
requestLayout()
Call this when something has changed which has invalidated the layout of this view. |
void
|
requestPointerCapture()
Requests pointer capture mode. |
boolean
|
requestRectangleOnScreen(Rect rectangle, boolean immediate, int source)
Request that a rectangle of this view be visible on the screen, scrolling if necessary just enough. |
boolean
|
requestRectangleOnScreen(Rect rectangle)
Request that a rectangle of this view be visible on the screen, scrolling if necessary just enough. |
boolean
|
requestRectangleOnScreen(Rect rectangle, boolean immediate)
Request that a rectangle of this view be visible on the screen, scrolling if necessary just enough. |
final
void
|
requestUnbufferedDispatch(int source)
Request unbuffered dispatch of the given event source class to this view. |
final
void
|
requestUnbufferedDispatch(MotionEvent event)
Request unbuffered dispatch of the given stream of MotionEvents to this View. |
final
<T extends View>
T
|
requireViewById(int id)
Finds the first descendant view with the given ID, the view itself if the ID matches
|
void
|
resetPivot()
Clears any pivot previously set by a call to |
static
int
|
resolveSize(int size, int measureSpec)
Version of |
static
int
|
resolveSizeAndState(int size, int measureSpec, int childMeasuredState)
Utility to reconcile a desired size and state, with constraints imposed by a MeasureSpec. |
boolean
|
restoreDefaultFocus()
Gives focus to the default-focus view in the view hierarchy that has this view as a root. |
void
|
restoreHierarchyState(SparseArray<Parcelable> container)
Restore this view hierarchy's frozen state from the given container. |
final
void
|
saveAttributeDataForStyleable(Context context, int[] styleable, AttributeSet attrs, TypedArray t, int defStyleAttr, int defStyleRes)
Stores debugging information about attributes. |
void
|
saveHierarchyState(SparseArray<Parcelable> container)
Store this view hierarchy's frozen state into the given container. |
void
|
scheduleDrawable(Drawable who, Runnable what, long when)
Schedules an action on a drawable to occur at a specified time. |
void
|
scrollBy(int x, int y)
Move the scrolled position of your view. |
void
|
scrollTo(int x, int y)
Set the scrolled position of your view. |
void
|
sendAccessibilityEvent(int eventType)
Sends an accessibility event of the given type. |
void
|
sendAccessibilityEventUnchecked(AccessibilityEvent event)
This method behaves exactly as |
void
|
setAccessibilityDataSensitive(int accessibilityDataSensitive)
Specifies whether this view should only allow interactions from
|
void
|
setAccessibilityDelegate(View.AccessibilityDelegate delegate)
Sets a delegate for implementing accessibility support via composition (as opposed to inheritance). |
void
|
setAccessibilityHeading(boolean isHeading)
Set if view is a heading for a section of content for accessibility purposes. |
void
|
setAccessibilityLiveRegion(int mode)
Sets the live region mode for this view. |
void
|
setAccessibilityPaneTitle(CharSequence accessibilityPaneTitle)
Visually distinct portion of a window with window-like semantics are considered panes for accessibility purposes. |
void
|
setAccessibilityTraversalAfter(int afterId)
Sets the id of a view that screen readers are requested to visit before this view. |
void
|
setAccessibilityTraversalBefore(int beforeId)
Sets the id of a view that screen readers are requested to visit after this view. |
void
|
setActivated(boolean activated)
Changes the activated state of this view. |
void
|
setAllowClickWhenDisabled(boolean clickableWhenDisabled)
Enables or disables click events for this view when disabled. |
void
|
setAllowedHandwritingDelegatePackage(String allowedPackageName)
Specifies that this view may act as a handwriting initiation delegator for a delegate editor view from the specified package. |
void
|
setAllowedHandwritingDelegatorPackage(String allowedPackageName)
Specifies that a view from the specified package may act as a handwriting delegator for this delegate editor view. |
void
|
setAlpha(float alpha)
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. |
void
|
setAnimation(Animation animation)
Sets the next animation to play for this view. |
void
|
setAnimationMatrix(Matrix matrix)
Changes the transformation matrix on the view. |
void
|
setAutoHandwritingEnabled(boolean enabled)
Set whether this view enables automatic handwriting initiation. |
void
|
setAutofillHints(String... autofillHints)
Sets the hints that help an |
void
|
setAutofillId(AutofillId id)
Sets the unique, logical identifier of this view in the activity, for autofill purposes. |
void
|
setBackground(Drawable background)
Set the background to a given Drawable, or remove the background. |
void
|
setBackgroundColor(int color)
Sets the background color for this view. |
void
|
setBackgroundDrawable(Drawable background)
This method was deprecated
in API level 16.
use |
void
|
setBackgroundResource(int resid)
Set the background to a given resource. |
void
|
setBackgroundTintBlendMode(BlendMode blendMode)
Specifies the blending mode used to apply the tint specified by
|
void
|
setBackgroundTintList(ColorStateList tint)
Applies a tint to the background drawable. |
void
|
setBackgroundTintMode(PorterDuff.Mode tintMode)
Specifies the blending mode used to apply the tint specified by
|
final
void
|
setBottom(int bottom)
Sets the bottom position of this view relative to its parent. |
void
|
setCameraDistance(float distance)
Sets the distance along the Z axis (orthogonal to the X/Y plane on which views are drawn) from the camera to this view. |
void
|
setClickable(boolean clickable)
Enables or disables click events for this view. |
void
|
setClipBounds(Rect clipBounds)
Sets a rectangular area on this view to which the view will be clipped when it is drawn. |
void
|
setClipToOutline(boolean clipToOutline)
Sets whether the View's Outline should be used to clip the contents of the View. |
void
|
setContentCaptureSession(ContentCaptureSession contentCaptureSession)
Sets the (optional) |
void
|
setContentDescription(CharSequence contentDescription)
Sets the |
final
void
|
setContentSensitivity(int mode)
Sets content sensitivity mode to determine whether this view displays sensitive content (e.g. username, password etc.). |
void
|
setContextClickable(boolean contextClickable)
Enables or disables context clicking for this view. |
void
|
setDefaultFocusHighlightEnabled(boolean defaultFocusHighlightEnabled)
Sets whether this View should use a default focus highlight when it gets focused but doesn't
have |
void
|
setDrawingCacheBackgroundColor(int color)
This method was deprecated
in API level 28.
The view drawing cache was largely made obsolete with the introduction of
hardware-accelerated rendering in API 11. With hardware-acceleration, intermediate cache
layers are largely unnecessary and can easily result in a net loss in performance due to the
cost of creating and updating the layer. In the rare cases where caching layers are useful,
such as for alpha animations, |
void
|
setDrawingCacheEnabled(boolean enabled)
This method was deprecated
in API level 28.
The view drawing cache was largely made obsolete with the introduction of
hardware-accelerated rendering in API 11. With hardware-acceleration, intermediate cache
layers are largely unnecessary and can easily result in a net loss in performance due to the
cost of creating and updating the layer. In the rare cases where caching layers are useful,
such as for alpha animations, |
void
|
setDrawingCacheQuality(int quality)
This method was deprecated
in API level 28.
The view drawing cache was largely made obsolete with the introduction of
hardware-accelerated rendering in API 11. With hardware-acceleration, intermediate cache
layers are largely unnecessary and can easily result in a net loss in performance due to the
cost of creating and updating the layer. In the rare cases where caching layers are useful,
such as for alpha animations, |
void
|
setDuplicateParentStateEnabled(boolean enabled)
Enables or disables the duplication of the parent's state into this view. |
void
|
setElevation(float elevation)
Sets the base elevation of this view, in pixels. |
void
|
setEnabled(boolean enabled)
Set the enabled state of this view. |
void
|
setFadingEdgeLength(int length)
Set the size of the faded edge used to indicate that more content in this view is available. |
void
|
setFilterTouchesWhenObscured(boolean enabled)
Sets whether the framework should discard touches when the view's window is obscured by another visible window at the touched location. |
void
|
setFitsSystemWindows(boolean fitSystemWindows)
Sets whether or not this view should account for system screen decorations
such as the status bar and inset its content; that is, controlling whether
the default implementation of |
void
|
setFocusable(boolean focusable)
Set whether this view can receive the focus. |
void
|
setFocusable(int focusable)
Sets whether this view can receive focus. |
void
|
setFocusableInTouchMode(boolean focusableInTouchMode)
Set whether this view can receive focus while in touch mode. |
void
|
setFocusedByDefault(boolean isFocusedByDefault)
Sets whether this View should receive focus when the focus is restored for the view hierarchy containing this view. |
void
|
setForceDarkAllowed(boolean allow)
Sets whether or not to allow force dark to apply to this view. |
void
|
setForeground(Drawable foreground)
Supply a Drawable that is to be rendered on top of all of the content in the view. |
void
|
setForegroundGravity(int gravity)
Describes how the foreground is positioned. |
void
|
setForegroundTintBlendMode(BlendMode blendMode)
Specifies the blending mode used to apply the tint specified by
|
void
|
setForegroundTintList(ColorStateList tint)
Applies a tint to the foreground drawable. |
void
|
setForegroundTintMode(PorterDuff.Mode tintMode)
Specifies the blending mode used to apply the tint specified by
|
void
|
setFrameContentVelocity(float pixelsPerSecond)
Set the current velocity of the View, we only track positive value. |
void
|
setHandwritingBoundsOffsets(float offsetLeft, float offsetTop, float offsetRight, float offsetBottom)
Set the amount of offset applied to this view's stylus handwriting bounds. |
void
|
setHandwritingDelegateFlags(int flags)
Sets flags configuring the handwriting delegation behavior for this delegate editor view. |
void
|
setHandwritingDelegatorCallback(Runnable callback)
Sets a callback which should be called when a stylus |
void
|
setHapticFeedbackEnabled(boolean hapticFeedbackEnabled)
Set whether this view should have haptic feedback for events such as long presses. |
void
|
setHasTransientState(boolean hasTransientState)
Set whether this view is currently tracking transient state that the framework should attempt to preserve when possible. |
void
|
setHorizontalFadingEdgeEnabled(boolean horizontalFadingEdgeEnabled)
Define whether the horizontal edges should be faded when this view is scrolled horizontally. |
void
|
setHorizontalScrollBarEnabled(boolean horizontalScrollBarEnabled)
Define whether the horizontal scrollbar should be drawn or not. |
void
|
setHorizontalScrollbarThumbDrawable(Drawable drawable)
Defines the horizontal thumb drawable |
void
|
setHorizontalScrollbarTrackDrawable(Drawable drawable)
Defines the horizontal track drawable |
void
|
setHovered(boolean hovered)
Sets whether the view is currently hovered. |
void
|
setId(int id)
Sets the identifier for this view. |
void
|
setImportantForAccessibility(int mode)
Sets how to determine whether this view is important for accessibility which is if it fires accessibility events and if it is reported to accessibility services that query the screen. |
void
|
setImportantForAutofill(int mode)
Sets the mode for determining whether this view is considered important for autofill. |
void
|
setImportantForContentCapture(int mode)
Sets the mode for determining whether this view is considered important for content capture. |
void
|
setIsCredential(boolean isCredential)
Sets whether this view is a credential for Credential Manager purposes. |
void
|
setIsHandwritingDelegate(boolean isHandwritingDelegate)
Sets this view to be a handwriting delegate. |
void
|
setKeepScreenOn(boolean keepScreenOn)
Controls whether the screen should remain on, modifying the
value of |
void
|
setKeyboardNavigationCluster(boolean isCluster)
Set whether this view is a root of a keyboard navigation cluster. |
void
|
setLabelFor(int id)
Sets the id of a view for which this view serves as a label for accessibility purposes. |
void
|
setLayerPaint(Paint paint)
Updates the |
void
|
setLayerType(int layerType, Paint paint)
Specifies the type of layer backing this view. |
void
|
setLayoutDirection(int layoutDirection)
Set the layout direction for this view. |
void
|
setLayoutParams(ViewGroup.LayoutParams params)
Set the layout parameters associated with this view. |
final
void
|
setLeft(int left)
Sets the left position of this view relative to its parent. |
final
void
|
setLeftTopRightBottom(int left, int top, int right, int bottom)
Assign a size and position to this view. |
void
|
setLongClickable(boolean longClickable)
Enables or disables long click events for this view. |
void
|
setMinimumHeight(int minHeight)
Sets the minimum height of the view. |
void
|
setMinimumWidth(int minWidth)
Sets the minimum width of the view. |
void
|
setNestedScrollingEnabled(boolean enabled)
Enable or disable nested scrolling for this view. |
void
|
setNextClusterForwardId(int nextClusterForwardId)
Sets the id of the view to use as the root of the next keyboard navigation cluster. |
void
|
setNextFocusDownId(int nextFocusDownId)
Sets the id of the view to use when the next focus is |
void
|
setNextFocusForwardId(int nextFocusForwardId)
Sets the id of the view to use when the next focus is |
void
|
setNextFocusLeftId(int nextFocusLeftId)
Sets the id of the view to use when the next focus is |
void
|
setNextFocusRightId(int nextFocusRightId)
Sets the id of the view to use when the next focus is |
void
|
setNextFocusUpId(int nextFocusUpId)
Sets the id of the view to use when the next focus is |
void
|
setOnApplyWindowInsetsListener(View.OnApplyWindowInsetsListener listener)
Set an |
void
|
setOnCapturedPointerListener(View.OnCapturedPointerListener l)
Set a listener to receive callbacks when the pointer capture state of a view changes. |
void
|
setOnClickListener(View.OnClickListener l)
Register a callback to be invoked when this view is clicked. |
void
|
setOnContextClickListener(View.OnContextClickListener l)
Register a callback to be invoked when this view is context clicked. |
void
|
setOnCreateContextMenuListener(View.OnCreateContextMenuListener l)
Register a callback to be invoked when the context menu for this view is being built. |
void
|
setOnDragListener(View.OnDragListener l)
Register a drag event listener callback object for this View. |
void
|
setOnFocusChangeListener(View.OnFocusChangeListener l)
Register a callback to be invoked when focus of this view changed. |
void
|
setOnGenericMotionListener(View.OnGenericMotionListener l)
Register a callback to be invoked when a generic motion event is sent to this view. |
void
|
setOnHoverListener(View.OnHoverListener l)
Register a callback to be invoked when a hover event is sent to this view. |
void
|
setOnKeyListener(View.OnKeyListener l)
Register a callback to be invoked when a hardware key is pressed in this view. |
void
|
setOnLongClickListener(View.OnLongClickListener l)
Register a callback to be invoked when this view is clicked and held. |
void
|
setOnReceiveContentListener(String[] mimeTypes, OnReceiveContentListener listener)
Sets the listener to be |
void
|
setOnScrollChangeListener(View.OnScrollChangeListener l)
Register a callback to be invoked when the scroll X or Y positions of this view change. |
void
|
setOnSystemUiVisibilityChangeListener(View.OnSystemUiVisibilityChangeListener l)
This method was deprecated
in API level 30.
Use |
void
|
setOnTouchListener(View.OnTouchListener l)
Register a callback to be invoked when a touch event is sent to this view. |
void
|
setOutlineAmbientShadowColor(int color)
Sets the color of the ambient shadow that is drawn when the view has a positive Z or elevation value. |
void
|
setOutlineProvider(ViewOutlineProvider provider)
Sets the |
void
|
setOutlineSpotShadowColor(int color)
Sets the color of the spot shadow that is drawn when the view has a positive Z or elevation value. |
void
|
setOverScrollMode(int overScrollMode)
Set the over-scroll mode for this view. |
void
|
setPadding(int left, int top, int right, int bottom)
Sets the padding. |
void
|
setPaddingRelative(int start, int top, int end, int bottom)
Sets the relative padding. |
void
|
setPendingCredentialRequest(GetCredentialRequest request, OutcomeReceiver<GetCredentialResponse, GetCredentialException> callback)
Sets a |
void
|
setPivotX(float pivotX)
Sets the x location of the point around which the view is
|
void
|
setPivotY(float pivotY)
Sets the y location of the point around which the view is |
void
|
setPointerIcon(PointerIcon pointerIcon)
Set the pointer icon to be used for a mouse pointer in the current view. |
final
void
|
setPreferKeepClear(boolean preferKeepClear)
Set a preference to keep the bounds of this view clear from floating windows above this view's window. |
final
void
|
setPreferKeepClearRects(List<Rect> rects)
Set a preference to keep the provided rects clear from floating windows above this view's window. |
void
|
setPressed(boolean pressed)
Sets the pressed state for this view. |
void
|
setRenderEffect(RenderEffect renderEffect)
Configure the |
void
|
setRequestedFrameRate(float frameRate)
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. |
final
void
|
setRevealOnFocusHint(boolean revealOnFocus)
Sets this view's preference for reveal behavior when it gains focus. |
final
void
|
setRight(int right)
Sets the right position of this view relative to its parent. |
void
|
setRotation(float rotation)
Sets the degrees that the view is rotated around the pivot point. |
void
|
setRotationX(float rotationX)
Sets the degrees that the view is rotated around the horizontal axis through the pivot point. |
void
|
setRotationY(float rotationY)
Sets the degrees that the view is rotated around the vertical axis through the pivot point. |
void
|
setSaveEnabled(boolean enabled)
Controls whether the saving of this view's state is
enabled (that is, whether its |
void
|
setSaveFromParentEnabled(boolean enabled)
Controls whether the entire hierarchy under this view will save its state when a state saving traversal occurs from its parent. |
void
|
setScaleX(float scaleX)
Sets the amount that the view is scaled in x around the pivot point, as a proportion of the view's unscaled width. |
void
|
setScaleY(float scaleY)
Sets the amount that the view is scaled in Y around the pivot point, as a proportion of the view's unscaled width. |
void
|
setScreenReaderFocusable(boolean screenReaderFocusable)
Sets whether this View should be a focusable element for screen readers and include non-focusable Views from its subtree when providing feedback. |
void
|
setScrollBarDefaultDelayBeforeFade(int scrollBarDefaultDelayBeforeFade)
Define the delay before scrollbars fade. |
void
|
setScrollBarFadeDuration(int scrollBarFadeDuration)
Define the scrollbar fade duration. |
void
|
setScrollBarSize(int scrollBarSize)
Define the scrollbar size. |
void
|
setScrollBarStyle(int style)
Specify the style of the scrollbars. |
final
void
|
setScrollCaptureCallback(ScrollCaptureCallback callback)
Sets the callback to receive scroll capture requests. |
void
|
setScrollCaptureHint(int hint)
Sets the scroll capture hint for this View. |
void
|
setScrollContainer(boolean isScrollContainer)
Change whether this view is one of the set of scrollable containers in its window. |
void
|
setScrollIndicators(int indicators, int mask)
Sets the state of the scroll indicators specified by the mask. |
void
|
setScrollIndicators(int indicators)
Sets the state of all scroll indicators. |
void
|
setScrollX(int value)
Set the horizontal scrolled position of your view. |
void
|
setScrollY(int value)
Set the vertical scrolled position of your view. |
void
|
setScrollbarFadingEnabled(boolean fadeScrollbars)
Define whether scrollbars will fade when the view is not scrolling. |
void
|
setSelected(boolean selected)
Changes the selection state of this view. |
void
|
setSoundEffectsEnabled(boolean soundEffectsEnabled)
Set whether this view should have sound effects enabled for events such as clicking and touching. |
void
|
setStateDescription(CharSequence stateDescription)
Sets the |
void
|
setStateListAnimator(StateListAnimator stateListAnimator)
Attaches the provided StateListAnimator to this View. |
void
|
setSupplementalDescription(CharSequence supplementalDescription)
Sets the |
void
|
setSystemGestureExclusionRects(List<Rect> rects)
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. |
void
|
setSystemUiVisibility(int visibility)
This method was deprecated
in API level 30.
SystemUiVisibility flags are deprecated. Use |
void
|
setTag(int key, Object tag)
Sets a tag associated with this view and a key. |
void
|
setTag(Object tag)
Sets the tag associated with this view. |
void
|
setTextAlignment(int textAlignment)
Set the text alignment. |
void
|
setTextDirection(int textDirection)
Set the text direction. |
void
|
setTooltipText(CharSequence tooltipText)
Sets the tooltip text which will be displayed in a small popup next to the view. |
final
void
|
setTop(int top)
Sets the top position of this view relative to its parent. |
void
|
setTouchDelegate(TouchDelegate delegate)
Sets the TouchDelegate for this View. |
void
|
setTransitionAlpha(float alpha)
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. |
final
void
|
setTransitionName(String transitionName)
Sets the name of the View to be used to identify Views in Transitions. |
void
|
setTransitionVisibility(int visibility)
Changes the visibility of this View without triggering any other changes. |
void
|
setTranslationX(float translationX)
Sets the horizontal location of this view relative to its |
void
|
setTranslationY(float translationY)
Sets the vertical location of this view relative to its |
void
|
setTranslationZ(float translationZ)
Sets the depth location of this view relative to its |