Java android.view View fields, constructors, methods, implement or subclass

Example usage for Java android.view View fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for android.view View.

The text is from its open source code.

Subclass

android.view.View has subclasses.
Click this link to see all its subclasses.

Implementation

android.view.View has the following implementations.
Click this link to see all its implementation.

Field

intNO_ID
Used to mark a View that has no ID.
intVISIBLE
This view is visible.
intINVISIBLE
This view is invisible, but it still takes up space for layout purposes.
intGONE
This view is invisible, and it doesn't take any space for layout purposes.
intDRAWING_CACHE_QUALITY_LOW

Enables low quality mode for the drawing cache.

intDRAWING_CACHE_QUALITY_HIGH

Enables high quality mode for the drawing cache.

intDRAWING_CACHE_QUALITY_AUTO

Enables automatic quality mode for the drawing cache.

intSCROLLBARS_INSIDE_OVERLAY
The scrollbar style to display the scrollbars inside the content area, without increasing the padding.
intSCROLLBARS_INSIDE_INSET
The scrollbar style to display the scrollbars inside the padded area, increasing the padding of the view.
intSCROLLBARS_OUTSIDE_OVERLAY
The scrollbar style to display the scrollbars at the edge of the view, without increasing the padding.
intSCROLLBARS_OUTSIDE_INSET
The scrollbar style to display the scrollbars at the edge of the view, increasing the padding of the view.
intFOCUS_BACKWARD
Use with #focusSearch(int) .
intFOCUS_FORWARD
Use with #focusSearch(int) .
intFOCUS_LEFT
Use with #focusSearch(int) .
intFOCUS_UP
Use with #focusSearch(int) .
intFOCUS_RIGHT
Use with #focusSearch(int) .
intFOCUS_DOWN
Use with #focusSearch(int) .
intMEASURED_SIZE_MASK
Bits of #getMeasuredWidthAndState() and #getMeasuredWidthAndState() that provide the actual measured size.
intMEASURED_STATE_MASK
Bits of #getMeasuredWidthAndState() and #getMeasuredWidthAndState() that provide the additional state bits.
intMEASURED_HEIGHT_STATE_SHIFT
Bit shift of #MEASURED_STATE_MASK to get to the height bits for functions that combine both width and height into a single int, such as #getMeasuredState() and the childState argument of #resolveSizeAndState(int,int,int) .
nullEMPTY_STATE_SET
Indicates the view has no states set.
nullPRESSED_ENABLED_STATE_SET
Indicates the view is pressed and enabled.
intLAYOUT_DIRECTION_LTR
Horizontal layout direction of this view is from Left to Right.
intLAYOUT_DIRECTION_RTL
Horizontal layout direction of this view is from Right to Left.
intLAYOUT_DIRECTION_INHERIT
Horizontal layout direction of this view is inherited from its parent.
intLAYOUT_DIRECTION_LOCALE
Horizontal layout direction of this view is from deduced from the default language script for the locale.
intTEXT_DIRECTION_INHERIT
Text direction is inherited through ViewGroup
intTEXT_DIRECTION_LTR
Text direction is forced to LTR.
intTEXT_DIRECTION_RTL
Text direction is forced to RTL.
intTEXT_DIRECTION_LOCALE
Text direction is coming from the system Locale.
intTEXT_ALIGNMENT_INHERIT
Default text alignment.
intTEXT_ALIGNMENT_GRAVITY
Default for the root view.
intTEXT_ALIGNMENT_TEXT_START
Align to the start of the paragraph, e.g.
intTEXT_ALIGNMENT_TEXT_END
Align to the end of the paragraph, e.g.
intTEXT_ALIGNMENT_CENTER
Center the paragraph, e.g.
intTEXT_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.
intTEXT_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.
intIMPORTANT_FOR_ACCESSIBILITY_AUTO
Automatically determine whether a view is important for accessibility.
intIMPORTANT_FOR_ACCESSIBILITY_YES
The view is important for accessibility.
intIMPORTANT_FOR_ACCESSIBILITY_NO
The view is not important for accessibility.
intIMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
The view is not important for accessibility, nor are any of its descendant views.
intACCESSIBILITY_LIVE_REGION_NONE
Live region mode specifying that accessibility services should not automatically announce changes to this view.
intACCESSIBILITY_LIVE_REGION_POLITE
Live region mode specifying that accessibility services should announce changes to this view.
intACCESSIBILITY_LIVE_REGION_ASSERTIVE
Live region mode specifying that accessibility services should interrupt ongoing speech to immediately announce changes to this view.
intOVER_SCROLL_ALWAYS
Always allow a user to over-scroll this view, provided it is a view that can scroll.
intOVER_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.
intOVER_SCROLL_NEVER
Never allow a user to over-scroll this view.
intSYSTEM_UI_FLAG_VISIBLE
Special constant for #setSystemUiVisibility(int) : View has requested the system UI (status bar) to be visible (the default).
intSYSTEM_UI_FLAG_LOW_PROFILE
Flag for #setSystemUiVisibility(int) : View has requested the system UI to enter an unobtrusive "low profile" mode.
intSYSTEM_UI_FLAG_HIDE_NAVIGATION
Flag for #setSystemUiVisibility(int) : View has requested that the system navigation be temporarily hidden.
intSYSTEM_UI_FLAG_FULLSCREEN
Flag for #setSystemUiVisibility(int) : View has requested to go into the normal fullscreen mode so that its content can take over the screen while still allowing the user to interact with the application.
intSYSTEM_UI_FLAG_LAYOUT_STABLE
Flag for #setSystemUiVisibility(int) : When using other layout flags, we would like a stable view of the content insets given to #fitSystemWindows(Rect) .
intSYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
Flag for #setSystemUiVisibility(int) : View would like its window to be laid out as if it has requested #SYSTEM_UI_FLAG_HIDE_NAVIGATION , even if it currently hasn't.
intSYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
Flag for #setSystemUiVisibility(int) : View would like its window to be laid out as if it has requested #SYSTEM_UI_FLAG_FULLSCREEN , even if it currently hasn't.
intSYSTEM_UI_FLAG_IMMERSIVE
Flag for #setSystemUiVisibility(int) : View would like to remain interactive when hiding the navigation bar with #SYSTEM_UI_FLAG_HIDE_NAVIGATION .
intSYSTEM_UI_FLAG_IMMERSIVE_STICKY
Flag for #setSystemUiVisibility(int) : View would like to remain interactive when hiding the status bar with #SYSTEM_UI_FLAG_FULLSCREEN and/or hiding the navigation bar with #SYSTEM_UI_FLAG_HIDE_NAVIGATION .
intSYSTEM_UI_FLAG_LIGHT_STATUS_BAR
Flag for #setSystemUiVisibility(int) : Requests the status bar to draw in a mode that is compatible with light status bar backgrounds.
intSTATUS_BAR_HIDDEN
intSTATUS_BAR_VISIBLE
intSTATUS_BAR_DISABLE_HOME
intSTATUS_BAR_DISABLE_BACK
intSTATUS_BAR_DISABLE_RECENT
intFIND_VIEWS_WITH_TEXT
Find views that render the specified text.
intFIND_VIEWS_WITH_CONTENT_DESCRIPTION
Find find views that contain the specified content description.
intSCREEN_STATE_OFF
Indicates that the screen has changed state and is now off.
intSCREEN_STATE_ON
Indicates that the screen has changed state and is now on.
intSCROLL_AXIS_VERTICAL
Indicates scrolling along the vertical axis.
intDRAG_FLAG_GLOBAL
Flag indicating that a drag can cross window boundaries.
intDRAG_FLAG_GLOBAL_URI_READ
When this flag is used with #DRAG_FLAG_GLOBAL , the drag recipient will be able to request read access to the content URI(s) contained in the ClipData object.
intSCROLLBAR_POSITION_DEFAULT
Position the scroll bar at the default position as determined by the system.
intSCROLLBAR_POSITION_LEFT
Position the scroll bar along the left edge.
intSCROLLBAR_POSITION_RIGHT
Position the scroll bar along the right edge.
intLAYER_TYPE_NONE
Indicates that the view does not have a layer.
intLAYER_TYPE_SOFTWARE

Indicates that the view has a software layer.

intLAYER_TYPE_HARDWARE

Indicates that the view has a hardware layer.

PropertyALPHA
A Property wrapper around the alpha functionality handled by the View#setAlpha(float) and View#getAlpha() methods.
PropertyTRANSLATION_X
A Property wrapper around the translationX functionality handled by the View#setTranslationX(float) and View#getTranslationX() methods.
PropertyTRANSLATION_Y
A Property wrapper around the translationY functionality handled by the View#setTranslationY(float) and View#getTranslationY() methods.
PropertyTRANSLATION_Z
A Property wrapper around the translationZ functionality handled by the View#setTranslationZ(float) and View#getTranslationZ() methods.
PropertyX
A Property wrapper around the x functionality handled by the View#setX(float) and View#getX() methods.
PropertyY
A Property wrapper around the y functionality handled by the View#setY(float) and View#getY() methods.
PropertyZ
A Property wrapper around the z functionality handled by the View#setZ(float) and View#getZ() methods.
PropertyROTATION
A Property wrapper around the rotation functionality handled by the View#setRotation(float) and View#getRotation() methods.
PropertyROTATION_X
A Property wrapper around the rotationX functionality handled by the View#setRotationX(float) and View#getRotationX() methods.
PropertyROTATION_Y
A Property wrapper around the rotationY functionality handled by the View#setRotationY(float) and View#getRotationY() methods.
PropertySCALE_X
A Property wrapper around the scaleX functionality handled by the View#setScaleX(float) and View#getScaleX() methods.
PropertySCALE_Y
A Property wrapper around the scaleY functionality handled by the View#setScaleY(float) and View#getScaleY() methods.

Constructor

View(Context context)
Simple constructor to use when creating a view from code.
View(Context context, @Nullable AttributeSet attrs)
Constructor that is called when inflating a view from XML.

Method

voidaddChildrenForAccessibility(ArrayList outChildren)
Adds the children of this View relevant for accessibility to the given list as output.
voidaddFocusables(ArrayList views, @FocusDirection int direction, @FocusableMode int focusableMode)
Adds any focusable views that are descendants of this view (possibly including this view if it is focusable itself) to views.
voidaddFocusables(ArrayList views, @FocusDirection int direction)
Add any focusable views that are descendants of this view (possibly including this view if it is focusable itself) to views.
voidaddOnAttachStateChangeListener(OnAttachStateChangeListener listener)
Add a listener for attach state changes.
voidaddOnLayoutChangeListener(OnLayoutChangeListener listener)
Add a listener that will be called when the bounds of the view change due to layout processing.
voidaddTouchables(ArrayList views)
Add any touchable views that are descendants of this view (possibly including this view if it is touchable itself) to views.
ViewPropertyAnimatoranimate()
This method returns a ViewPropertyAnimator object, which can be used to animate specific properties on this View.
voidannounceForAccessibility(CharSequence text)
Convenience method for sending a AccessibilityEvent#TYPE_ANNOUNCEMENT AccessibilityEvent to make an announcement which is related to some sort of a context change for which none of the events representing UI transitions is a good fit.
voidbringToFront()
Change the view's z order in the tree, so it's on top of other sibling views.
voidbuildDrawingCache()

Calling this method is equivalent to calling buildDrawingCache(false).

voidbuildDrawingCache(boolean autoScale)

Forces the drawing cache to be built if the drawing cache is invalid.

If you call #buildDrawingCache() manually without calling #setDrawingCacheEnabled(boolean) setDrawingCacheEnabled(true) , you should cleanup the cache by calling #destroyDrawingCache() afterwards.

Note about auto scaling in compatibility mode: When auto scaling is not enabled, this method will create a bitmap of the same size as this view.

voidbuildLayer()
Forces this view's layer to be created and this view to be rendered into its layer.
booleancallOnClick()
Directly call any attached OnClickListener.
voidcancel()
Set #FLAG_CANCELED flag for the key event.
voidcancelLongPress()
Cancels a pending long press.
voidcancelPendingInputEvents()
Cancel any deferred high-level input events that were previously posted to the event queue.
booleancanScrollHorizontally(int direction)
Check if this view can be scrolled horizontally in a certain direction.
booleancanScrollVertically(int direction)
Check if this view can be scrolled vertically in a certain direction.
voidclearAnimation()
Cancels any animations for this view.
voidclearFocus()
Called when this view wants to give up focus.
intcombineMeasuredStates(int curState, int newState)
Merge two states as returned by #getMeasuredState() .
voidcomputeScroll()
Called by a parent to request that a child update its values for mScrollX and mScrollY if necessary.
AccessibilityNodeInfocreateAccessibilityNodeInfo()
Returns an AccessibilityNodeInfo representing this view from the point of view of an android.accessibilityservice.AccessibilityService .
voiddestroyDrawingCache()

Frees the resources used by the drawing cache.

booleandispatchKeyEvent(KeyEvent event)
Dispatch a key event to the next view on the focus path.
booleandispatchPopulateAccessibilityEvent(AccessibilityEvent event)
Dispatches an AccessibilityEvent to the View first and then to its children for adding their text content to the event.
booleandispatchTouchEvent(MotionEvent event)
Pass the touch screen motion event down to the target view, or this view if it is the target.
voiddraw(Canvas canvas)
Manually render this view (and all of its children) to the given Canvas.
voiddrawableHotspotChanged(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.
booleanequals(Object obj)
Indicates whether some other object is "equal to" this one.
ViewfindFocus()
Find the view in the hierarchy rooted at this view that currently has focus.
TfindViewById(@IdRes int id)
Finds the first descendant view with the given ID, the view itself if the ID matches #getId() , or null if the ID is invalid (< 0) or there is no matching view in the hierarchy.
TfindViewWithTag(Object tag)
Look for a child view with the given tag.
ViewfocusSearch(@FocusRealDirection int direction)
Find the nearest view in the specified direction that can take focus.
voidforceLayout()
Forces this view to be laid out during the next layout pass.
intgenerateViewId()
Generate a value suitable for use in #setId(int) .
AccessibilityNodeProvidergetAccessibilityNodeProvider()
Gets the provider for managing a virtual view hierarchy rooted at this View and reported to android.accessibilityservice.AccessibilityService s that explore the window content.
floatgetAlpha()
The opacity of the view.
AnimationgetAnimation()
Get the animation currently associated with this view.
IBindergetApplicationWindowToken()
Retrieve a unique token identifying the top-level "real" window of the window that this view is attached to.
DrawablegetBackground()
Gets the background drawable
intgetBaseline()

Return the offset of the widget's text baseline from the widget's top boundary.

intgetBottom()
Bottom position of this view relative to its parent.
ClassgetClass()
Returns the runtime class of this Object .
booleangetClipToOutline()
Returns whether the Outline should be used to clip the contents of the View.
CharSequencegetContentDescription()
Returns the View 's content description.
ContextgetContext()
Returns the context the view is running in, through which it can access the current theme, resources, etc.
intgetDefaultSize(int size, int measureSpec)
Utility to return a default size.
DisplaygetDisplay()
Gets the logical display to which the view's window has been attached.
int[]getDrawableState()
Return an array of resource IDs of the drawable states representing the current state of the view.
BitmapgetDrawingCache(boolean autoScale)

Returns the bitmap in which this view drawing is cached.

BitmapgetDrawingCache()

Calling this method is equivalent to calling getDrawingCache(false).

intgetDrawingCacheBackgroundColor()
voidgetDrawingRect(Rect outRect)
Return the visible drawing bounds of your view.
longgetDrawingTime()

Return the time at which the drawing of the view hierarchy started.

floatgetElevation()
The base elevation of this view relative to its parent, in pixels.
booleangetFitsSystemWindows()
Check for state of #setFitsSystemWindows(boolean) .
voidgetFocusedRect(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.
DrawablegetForeground()
Returns the drawable used as the foreground of this View.
booleangetGlobalVisibleRect(Rect r)
HandlergetHandler()
intgetHeight()
Return the height of your view.
voidgetHitRect(Rect outRect)
Hit rectangle in parent's coordinates
intgetId()
Returns this view's identifier.
intgetImportantForAccessibility()
Gets the mode for determining whether this View is important for accessibility.
KeyEvent.DispatcherStategetKeyDispatcherState()
Return the global KeyEvent.DispatcherState KeyEvent.DispatcherState for this view's window.
intgetLabelFor()
Gets the id of a view for which this view serves as a label for accessibility purposes.
intgetLayerType()
Indicates what type of layer is currently associated with this view.
intgetLayoutDirection()
Returns the resolved layout direction for this view.
ViewGroup.LayoutParamsgetLayoutParams()
Get the LayoutParams associated with this view.
intgetLeft()
Left position of this view relative to its parent.
booleangetLocalVisibleRect(Rect r)
voidgetLocationInWindow(@Size(2) int[] outLocation)

Computes the coordinates of this view in its window.

voidgetLocationOnScreen(@Size(2) int[] outLocation)

Computes the coordinates of this view on the screen.

int[]getLocationOnScreen()
MatrixgetMatrix()
The transform matrix of this view, which is calculated based on the current rotation, scale, and pivot properties.
intgetMeasuredHeight()
Like #getMeasuredHeightAndState() , but only returns the raw height component (that is the result is masked by #MEASURED_SIZE_MASK ).
intgetMeasuredHeightAndState()
Return the full height measurement information for this view as computed by the most recent call to #measure(int,int) .
intgetMeasuredState()
Return only the state bits of #getMeasuredWidthAndState() and #getMeasuredHeightAndState() , combined into one integer.
intgetMeasuredWidth()
Like #getMeasuredWidthAndState() , but only returns the raw width component (that is the result is masked by #MEASURED_SIZE_MASK ).
intgetMeasuredWidthAndState()
Return the full width measurement information for this view as computed by the most recent call to #measure(int,int) .
intgetNextFocusDownId()
Gets the id of the view to use when the next focus is #FOCUS_DOWN .
intgetNextFocusLeftId()
Gets the id of the view to use when the next focus is #FOCUS_LEFT .
intgetNextFocusRightId()
Gets the id of the view to use when the next focus is #FOCUS_RIGHT .
intgetNextFocusUpId()
Gets the id of the view to use when the next focus is #FOCUS_UP .
OnFocusChangeListenergetOnFocusChangeListener()
Returns the focus-change callback registered for this view.
ViewOutlineProvidergetOutlineProvider()
Returns the current ViewOutlineProvider of the view, which generates the Outline that defines the shape of the shadow it casts, and enables outline clipping.
ViewOverlaygetOverlay()
Returns the overlay for this view, creating it if it does not yet exist.
intgetPaddingBottom()
Returns the bottom padding of this view.
intgetPaddingEnd()
Returns the end padding of this view depending on its resolved layout direction.
intgetPaddingLeft()
Returns the left padding of this view.
intgetPaddingRight()
Returns the right padding of this view.
intgetPaddingStart()
Returns the start padding of this view depending on its resolved layout direction.
intgetPaddingTop()
Returns the top padding of this view.
ViewParentgetParent()
Gets the parent of this view.
ViewParentgetParentForAccessibility()
Gets the parent for accessibility purposes.
floatgetPivotX()
The x location of the point around which the view is #setRotation(float) rotated and #setScaleX(float) scaled .
floatgetPivotY()
The y location of the point around which the view is #setRotation(float) rotated and #setScaleY(float) scaled .
ResourcesgetResources()
Returns the resources associated with this view.
intgetRight()
Right position of this view relative to its parent.
ViewgetRootView()

Finds the topmost view in the current view hierarchy.

floatgetRotation()
The degrees that the view is rotated around the pivot point.
floatgetRotationY()
The degrees that the view is rotated around the vertical axis through the pivot point.
floatgetScaleX()
The amount that the view is scaled in x around the pivot point, as a proportion of the view's unscaled width.
floatgetScaleY()
The amount that the view is scaled in y around the pivot point, as a proportion of the view's unscaled height.
intgetScrollX()
Return the scrolled left position of this view.
intgetScrollY()
Return the scrolled top position of this view.
intgetSystemUiVisibility()
Returns the last #setSystemUiVisibility(int) that this view has requested.
ObjectgetTag(int key)
Returns the tag associated with this view and the specified key.
ObjectgetTag()
Returns this view's tag.
intgetTop()
Top position of this view relative to its parent.
ArrayListgetTouchables()
Find and return all touchable views that are descendants of this view, possibly including this view if it is touchable itself.
TouchDelegategetTouchDelegate()
Gets the TouchDelegate for this View.
StringgetTransitionName()
Returns the name of the View to be used to identify Views in Transitions.
floatgetTranslationX()
The horizontal location of this view relative to its #getLeft() left position.
floatgetTranslationY()
The vertical location of this view relative to its #getTop() top position.
intgetVerticalScrollbarPosition()
ViewTreeObservergetViewTreeObserver()
Returns the ViewTreeObserver for this view's hierarchy.
intgetVisibility()
Returns the visibility status for this view.
intgetWidth()
Return the width of your view.
intgetWindowSystemUiVisibility()
Returns the current system UI visibility that is currently set for the entire window.
IBindergetWindowToken()
Retrieve a unique token identifying the window this view is attached to.
voidgetWindowVisibleDisplayFrame(Rect outRect)
Retrieve the overall visible display size in which the window this view is attached to has been positioned in.
floatgetX()
The visual x position of this view, in pixels.
floatgetY()
The visual y position of this view, in pixels.
floatgetZ()
The visual z position of this view, in pixels.
booleanhasFocus()
Returns true if this view has focus itself, or is the ancestor of the view that has focus.
booleanhasFocusable()
Returns true if this view is focusable or if it contains a reachable View for which #hasFocusable() returns true .
inthashCode()
Returns a hash code value for the object.
booleanhasOnClickListeners()
Return whether this view has an attached OnClickListener.
booleanhasTransientState()
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.
booleanhasWindowFocus()
Returns true if this view is in a window that currently has window focus.
Viewinflate(Context context, @LayoutRes int resource, ViewGroup root)
Inflate a view from an XML resource.
voidinvalidate()
Invalidate the whole view.
voidinvalidate(int l, int t, int r, int b)
Mark the area defined by the rect (l,t,r,b) as needing to be drawn.
voidinvalidate(Rect dirty)
Mark the area defined by dirty as needing to be drawn.
voidinvalidate(boolean invalidateCache)
This is where the invalidate() work actually happens.
voidinvalidateOutline()
Called to rebuild this View's Outline from its ViewOutlineProvider outline provider
booleanisActivated()
Indicates the activation state of this view.
booleanisAttachedToWindow()
Returns true if this view is currently attached to a window.
booleanisClickable()
Indicates whether this view reacts to click events or not.
booleanisDrawingCacheEnabled()

Indicates whether the drawing cache is enabled for this view.

booleanisEnabled()
Returns the enabled status for this view.
booleanisFocusable()
Returns whether this View is currently able to take focus.
booleanisFocused()
Returns true if this view has focus
booleanisHorizontalScrollBarEnabled()

Indicate whether the horizontal scrollbar should be drawn or not.

booleanisImportantForAccessibility()
Computes whether this view should be exposed for accessibility.
booleanisInEditMode()
Indicates whether this View is currently in edit mode.
booleanisInLayout()
Returns whether the view hierarchy is currently undergoing a layout pass.
booleanisInTouchMode()
Returns whether the device is currently in touch mode.
booleanisLayoutRequested()

Indicates whether or not this view's layout will be requested during the next hierarchy layout pass.

booleanisLongClickable()
Indicates whether this view reacts to long click events or not.
booleanisOpaque()
Indicates whether this View is opaque.
booleanisPressed()
Indicates whether the view is currently in pressed state.
booleanisScrollContainer()
Indicates whether this view is one of the set of scrollable containers in its window.
booleanisSelected()
Indicates the selection state of this view.
booleanisShown()
Returns the visibility of this view and all of its ancestors
booleanisVerticalScrollBarEnabled()

Indicate whether the vertical scrollbar should be drawn or not.

voidjumpDrawablesToCurrentState()
Call Drawable#jumpToCurrentState() Drawable.jumpToCurrentState() on all Drawable objects associated with this view.
voidlayout(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.

voidmeasure(int widthMeasureSpec, int heightMeasureSpec)

This is called to find out how big a view should be.

voidoffsetLeftAndRight(int offset)
Offset this view's horizontal location by the specified amount of pixels.
voidoffsetTopAndBottom(int offset)
Offset this view's vertical location by the specified number of pixels.
WindowInsetsonApplyWindowInsets(WindowInsets insets)
Called when the view should apply WindowInsets according to its internal policy.
booleanonCheckIsTextEditor()
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.
voidonFinishTemporaryDetach()
Called after #onStartTemporaryDetach when the container is done changing the view.
voidonInitializeAccessibilityEvent(AccessibilityEvent event)
Initializes an AccessibilityEvent with information about this View which is the event source.
booleanonKeyDown(int keyCode, KeyEvent event)
Default implementation of KeyEvent.Callback#onKeyDown(int,KeyEvent) KeyEvent.Callback.onKeyDown() : perform press of the view when KeyEvent#KEYCODE_DPAD_CENTER or KeyEvent#KEYCODE_ENTER is released, if the view is enabled and clickable.
voidonStartTemporaryDetach()
This is called when a container is going to temporarily detach a child, with ViewGroup#detachViewFromParent(View) ViewGroup.detachViewFromParent .
booleanonTouchEvent(MotionEvent event)
Implement this method to handle touch screen motion events.
booleanperformClick()
Call this view's OnClickListener, if it is defined.
booleanperformHapticFeedback(int feedbackConstant)
BZZZTT!!1!
booleanperformHapticFeedback(int feedbackConstant, int flags)
BZZZTT!!1!
booleanperformLongClick()
Calls this view's OnLongClickListener, if it is defined.
voidplaySoundEffect(int soundConstant)
Play a sound effect for this view.
booleanpost(Runnable action)

Causes the Runnable to be added to the message queue.

booleanpostDelayed(Runnable action, long delayMillis)

Causes the Runnable to be added to the message queue, to be run after the specified amount of time elapses.

voidpostInvalidate()

Cause an invalidate to happen on a subsequent cycle through the event loop.

voidpostInvalidateDelayed(long delayMilliseconds)

Cause an invalidate to happen on a subsequent cycle through the event loop.

voidpostInvalidateOnAnimation()

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

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

voidpostOnAnimation(Runnable action)

Causes the Runnable to execute on the next animation time step.

voidpostOnAnimationDelayed(Runnable action, long delayMillis)

Causes the Runnable to execute on the next animation time step, after the specified amount of time elapses.

voidrefreshDrawableState()
Call this to force a view to update its drawable state.
booleanremoveCallbacks(Runnable action)

Removes the specified Runnable from the message queue.

voidremoveOnAttachStateChangeListener(OnAttachStateChangeListener listener)
Remove a listener for attach state changes.
voidremoveOnLayoutChangeListener(OnLayoutChangeListener listener)
Remove a listener for layout changes.
voidrequestApplyInsets()
Ask that a new dispatch of #onApplyWindowInsets(WindowInsets) be performed.
voidrequestFitSystemWindows()
Ask that a new dispatch of #fitSystemWindows(Rect) be performed.
booleanrequestFocus()
Call this to try to give focus to a specific view or to one of its descendants.
booleanrequestFocus(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.
booleanrequestFocus(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.
booleanrequestFocusFromTouch()
Call this to try to give focus to a specific view or to one of its descendants.
voidrequestLayout()
Call this when something has changed which has invalidated the layout of this view.
booleanrequestRectangleOnScreen(Rect rectangle, boolean immediate)
Request that a rectangle of this view be visible on the screen, scrolling if necessary just enough.
intresolveSize(int size, int measureSpec)
Version of #resolveSizeAndState(int,int,int) returning only the #MEASURED_SIZE_MASK bits of the result.
intresolveSizeAndState(int size, int measureSpec, int childMeasuredState)
Utility to reconcile a desired size and state, with constraints imposed by a MeasureSpec.
voidrestoreHierarchyState(SparseArray container)
Restore this view hierarchy's frozen state from the given container.
voidsaveHierarchyState(SparseArray container)
Store this view hierarchy's frozen state into the given container.
voidscrollBy(int x, int y)
Move the scrolled position of your view.
voidscrollTo(int x, int y)
Set the scrolled position of your view.
voidsendAccessibilityEvent(int eventType)
Sends an accessibility event of the given type.
voidsetAccessibilityDelegate(@Nullable AccessibilityDelegate delegate)
Sets a delegate for implementing accessibility support via composition (as opposed to inheritance).
voidsetAccessibilityTraversalAfter(int afterId)
Sets the id of a view after which this one is visited in accessibility traversal.
voidsetAccessibilityTraversalBefore(int beforeId)
Sets the id of a view before which this one is visited in accessibility traversal.
voidsetActivated(boolean activated)
Changes the activated state of this view.
voidsetAlpha(@FloatRange(from = 0.0, to = 1.0) 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.
voidsetAnimation(Animation animation)
Sets the next animation to play for this view.
voidsetBackground(Drawable background)
Set the background to a given Drawable, or remove the background.
voidsetBackgroundColor(@ColorInt int color)
Sets the background color for this view.
voidsetBackgroundDrawable(Drawable background)
voidsetBackgroundResource(@DrawableRes int resid)
Set the background to a given resource.
voidsetBottom(int bottom)
Sets the bottom position of this view relative to its parent.
voidsetCameraDistance(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.

voidsetClickable(boolean clickable)
Enables or disables click events for this view.
voidsetClipToOutline(boolean clipToOutline)
Sets whether the View's Outline should be used to clip the contents of the View.
voidsetContentDescription(CharSequence contentDescription)
Sets the View 's content description.
voidsetDrawingCacheBackgroundColor(@ColorInt int color)
Setting a solid background color for the drawing cache's bitmaps will improve performance and memory usage.
voidsetDrawingCacheEnabled(boolean enabled)

Enables or disables the drawing cache.

voidsetDrawingCacheQuality(@DrawingCacheQuality int quality)
Set the drawing cache quality of this view.
voidsetDuplicateParentStateEnabled(boolean enabled)

Enables or disables the duplication of the parent's state into this view.

voidsetElevation(float elevation)
Sets the base elevation of this view, in pixels.
voidsetEnabled(boolean enabled)
Set the enabled state of this view.
voidsetFadingEdgeLength(int length)
Set the size of the faded edge used to indicate that more content in this view is available.
voidsetFilterTouchesWhenObscured(boolean enabled)
Sets whether the framework should discard touches when the view's window is obscured by another visible window.
voidsetFitsSystemWindows(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 #fitSystemWindows(Rect) will be executed.
voidsetFocusable(boolean focusable)
Set whether this view can receive the focus.
voidsetFocusable(@Focusable int focusable)
Sets whether this view can receive focus.
voidsetFocusableInTouchMode(boolean focusableInTouchMode)
Set whether this view can receive focus while in touch mode.
voidsetForeground(Drawable foreground)
Supply a Drawable that is to be rendered on top of all of the content in the view.
voidsetHapticFeedbackEnabled(boolean hapticFeedbackEnabled)
Set whether this view should have haptic feedback for events such as long presses.
voidsetHasTransientState(boolean hasTransientState)
Set whether this view is currently tracking transient state that the framework should attempt to preserve when possible.
voidsetId(@IdRes int id)
Sets the identifier for this view.
voidsetImportantForAccessibility(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.
voidsetKeepScreenOn(boolean keepScreenOn)
Controls whether the screen should remain on, modifying the value of #KEEP_SCREEN_ON .
voidsetLayerPaint(@Nullable Paint paint)
Updates the Paint object used with the current layer (used only if the current layer type is not set to #LAYER_TYPE_NONE ).
voidsetLayerType(int layerType, @Nullable Paint paint)

Specifies the type of layer backing this view.

voidsetLayoutDirection(@LayoutDir int layoutDirection)
Set the layout direction for this view.
voidsetLayoutParams(ViewGroup.LayoutParams params)
Set the layout parameters associated with this view.
voidsetLeft(int left)
Sets the left position of this view relative to its parent.
voidsetLongClickable(boolean longClickable)
Enables or disables long click events for this view.
voidsetMinimumHeight(int minHeight)
Sets the minimum height of the view.
voidsetMinimumWidth(int minWidth)
Sets the minimum width of the view.
voidsetNextFocusDownId(int nextFocusDownId)
Sets the id of the view to use when the next focus is #FOCUS_DOWN .
voidsetNextFocusForwardId(int nextFocusForwardId)
Sets the id of the view to use when the next focus is #FOCUS_FORWARD .
voidsetNextFocusLeftId(int nextFocusLeftId)
Sets the id of the view to use when the next focus is #FOCUS_LEFT .
voidsetNextFocusRightId(int nextFocusRightId)
Sets the id of the view to use when the next focus is #FOCUS_RIGHT .
voidsetNextFocusUpId(int nextFocusUpId)
Sets the id of the view to use when the next focus is #FOCUS_UP .
voidsetOnApplyWindowInsetsListener(OnApplyWindowInsetsListener listener)
Set an OnApplyWindowInsetsListener to take over the policy for applying window insets to this view.
voidsetOnClickListener(@Nullable OnClickListener l)
Register a callback to be invoked when this view is clicked.
voidsetOnContextClickListener(@Nullable OnContextClickListener l)
Register a callback to be invoked when this view is context clicked.
voidsetOnCreateContextMenuListener(OnCreateContextMenuListener l)
Register a callback to be invoked when the context menu for this view is being built.
voidsetOnDragListener(OnDragListener l)
Register a drag event listener callback object for this View.
voidsetOnFocusChangeListener(OnFocusChangeListener l)
Register a callback to be invoked when focus of this view changed.
voidsetOnGenericMotionListener(OnGenericMotionListener l)
Register a callback to be invoked when a generic motion event is sent to this view.
voidsetOnHoverListener(OnHoverListener l)
Register a callback to be invoked when a hover event is sent to this view.
voidsetOnKeyListener(OnKeyListener l)
Register a callback to be invoked when a hardware key is pressed in this view.
voidsetOnLongClickListener(@Nullable OnLongClickListener l)
Register a callback to be invoked when this view is clicked and held.
voidsetOnScrollChangeListener(OnScrollChangeListener l)
Register a callback to be invoked when the scroll X or Y positions of this view change.
voidsetOnSystemUiVisibilityChangeListener(OnSystemUiVisibilityChangeListener l)
Set a listener to receive callbacks when the visibility of the system bar changes.
voidsetOnTouchListener(OnTouchListener l)
Register a callback to be invoked when a touch event is sent to this view.
voidsetOutlineProvider(ViewOutlineProvider provider)
Sets the ViewOutlineProvider of the view, which generates the Outline that defines the shape of the shadow it casts, and enables outline clipping.
voidsetOverScrollMode(int overScrollMode)
Set the over-scroll mode for this view.
voidsetPadding(int left, int top, int right, int bottom)
Sets the padding.
voidsetPaddingRelative(int start, int top, int end, int bottom)
Sets the relative padding.
voidsetPivotX(float pivotX)
Sets the x location of the point around which the view is #setRotation(float) rotated and #setScaleX(float) scaled .
voidsetPivotY(float pivotY)
Sets the y location of the point around which the view is #setRotation(float) rotated and #setScaleY(float) scaled .
voidsetPressed(boolean pressed)
Sets the pressed state for this view.
voidsetRight(int right)
Sets the right position of this view relative to its parent.
voidsetRotation(float rotation)
Sets the degrees that the view is rotated around the pivot point.
voidsetRotationX(float rotationX)
Sets the degrees that the view is rotated around the horizontal axis through the pivot point.
voidsetRotationY(float rotationY)
Sets the degrees that the view is rotated around the vertical axis through the pivot point.
voidsetSaveEnabled(boolean enabled)
Controls whether the saving of this view's state is enabled (that is, whether its #onSaveInstanceState method will be called).
voidsetScaleX(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.
voidsetScaleY(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.
voidsetScrollY(int value)
Set the vertical scrolled position of your view.
voidsetSelected(boolean selected)
Changes the selection state of this view.
voidsetSoundEffectsEnabled(boolean soundEffectsEnabled)
Set whether this view should have sound effects enabled for events such as clicking and touching.
voidsetSystemUiVisibility(int visibility)
Request that the visibility of the status bar or other screen/window decorations be changed.
voidsetTag(int key, final Object tag)
Sets a tag associated with this view and a key.
voidsetTag(final Object tag)
Sets the tag associated with this view.
voidsetTextAlignment(@TextAlignment int textAlignment)
Set the text alignment.
voidsetTextDirection(int textDirection)
Set the text direction.
voidsetTop(int top)
Sets the top position of this view relative to its parent.
voidsetTouchDelegate(TouchDelegate delegate)
Sets the TouchDelegate for this View.
voidsetTransitionName(String transitionName)
Sets the name of the View to be used to identify Views in Transitions.
voidsetTranslationX(float translationX)
Sets the horizontal location of this view relative to its #getLeft() left position.
voidsetTranslationY(float translationY)
Sets the vertical location of this view relative to its #getTop() top position.
voidsetTranslationZ(float translationZ)
Sets the depth location of this view relative to its #getElevation() elevation .
voidsetVerticalScrollBarEnabled(boolean verticalScrollBarEnabled)

Define whether the vertical scrollbar should be drawn or not.

voidsetVisibility(@Visibility int visibility)
Set the visibility state of this view.
voidsetWillNotCacheDrawing(boolean willNotCacheDrawing)
When a View's drawing cache is enabled, drawing is redirected to an offscreen bitmap.
voidsetWillNotDraw(boolean willNotDraw)
If this view doesn't do any drawing on its own, set this flag to allow further optimizations.
voidsetX(float x)
Sets the visual x position of this view, in pixels.
voidsetY(float y)
Sets the visual y position of this view, in pixels.
voidsetZ(float z)
Sets the visual z position of this view, in pixels.
booleanshowContextMenu()
Shows the context menu for this view.
ActionModestartActionMode(ActionMode.Callback callback)
Start an action mode with the default type ActionMode#TYPE_PRIMARY .
voidstartAnimation(Animation animation)
Start the specified animation now.
booleanstartDrag(ClipData data, DragShadowBuilder shadowBuilder, Object myLocalState, int flags)
booleanstartDragAndDrop(ClipData data, DragShadowBuilder shadowBuilder, Object myLocalState, int flags)
Starts a drag and drop operation.
StringtoString()
booleanwillNotCacheDrawing()
Returns whether or not this View can cache its drawing or not.
booleanwillNotDraw()
Returns whether or not this View draws on its own.