The randomaccessfile class treats a file as a stream of ________.

  • Platform
  • Android Studio
  • Google Play
  • Jetpack
  • Kotlin
  • Docs
    • Overview
    • Guides
    • Reference
    • Samples
    • Design & Quality
  • Games

Stay organized with collections Save and categorize content based on your preferences.

public class GridLayout
extends ViewGroup

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.GridLayout


A layout that places its children in a rectangular grid.

The grid is composed of a set of infinitely thin lines that separate the viewing area into cells. Throughout the API, grid lines are referenced by grid indices. A grid with N columns has N + 1 grid indices that run from 0 through N inclusive. Regardless of how GridLayout is configured, grid index 0 is fixed to the leading edge of the container and grid index N is fixed to its trailing edge (after padding is taken into account).

Row and Column Specs

Children occupy one or more contiguous cells, as defined by their rowSpec and columnSpec layout parameters. Each spec defines the set of rows or columns that are to be occupied; and how children should be aligned within the resulting group of cells. Although cells do not normally overlap in a GridLayout, GridLayout does not prevent children being defined to occupy the same cell or group of cells. In this case however, there is no guarantee that children will not themselves overlap after the layout operation completes.

Default Cell Assignment

If a child does not specify the row and column indices of the cell it wishes to occupy, GridLayout assigns cell locations automatically using its: orientation, rowCount and columnCount properties.

Space

Space between children may be specified either by using instances of the dedicated Space view or by setting the leftMargin, topMargin, rightMargin and bottomMargin layout parameters. When the useDefaultMargins property is set, default margins around children are automatically allocated based on the prevailing UI style guide for the platform. Each of the margins so defined may be independently overridden by an assignment to the appropriate layout parameter. Default values will generally produce a reasonable spacing between components but values may change between different releases of the platform.

Excess Space Distribution

As of API 21, GridLayout's distribution of excess space accomodates the principle of weight. In the event that no weights are specified, the previous conventions are respected and columns and rows are taken as flexible if their views specify some form of alignment within their groups.

The flexibility of a view is therefore influenced by its alignment which is, in turn, typically defined by setting the gravity property of the child's layout parameters. If either a weight or alignment were defined along a given axis then the component is taken as flexible in that direction. If no weight or alignment was set, the component is instead assumed to be inflexible.

Multiple components in the same row or column group are considered to act in parallel. Such a group is flexible only if all of the components within it are flexible. Row and column groups that sit either side of a common boundary are instead considered to act in series. The composite group made of these two elements is flexible if one of its elements is flexible.

To make a column stretch, make sure all of the components inside it define a weight or a gravity. To prevent a column from stretching, ensure that one of the components in the column does not define a weight or a gravity.

When the principle of flexibility does not provide complete disambiguation, GridLayout's algorithms favour rows and columns that are closer to its right and bottom edges. To be more precise, GridLayout treats each of its layout parameters as a constraint in the a set of variables that define the grid-lines along a given axis. During layout, GridLayout solves the constraints so as to return the unique solution to those constraints for which all variables are less-than-or-equal-to the corresponding value in any other valid solution.

Interpretation of GONE

For layout purposes, GridLayout treats views whose visibility status is GONE, as having zero width and height. This is subtly different from the policy of ignoring views that are marked as GONE outright. If, for example, a gone-marked view was alone in a column, that column would itself collapse to zero width if and only if no gravity was defined on the view. If gravity was defined, then the gone-marked view has no effect on the layout and the container should be laid out as if the view had never been added to it. GONE views are taken to have zero weight during excess space distribution.

These statements apply equally to rows as well as columns, and to groups of rows or columns.

See GridLayout.LayoutParams for a full description of the layout parameters used by GridLayout.

Summary

Nested classes

class GridLayout.Alignment

Alignments specify where a view should be placed within a cell group and what size it should be. 

class GridLayout.LayoutParams

Layout information associated with each of the children of a GridLayout. 

class GridLayout.Spec

A Spec defines the horizontal or vertical characteristics of a group of cells. 

XML attributes

android:alignmentMode When set to alignMargins, causes alignment to take place between the outer boundary of a view, as defined by its margins. 
android:columnCount The maximum number of columns to create when automatically positioning children. 
android:columnOrderPreserved When set to true, forces column boundaries to appear in the same order as column indices. 
android:orientation The orientation property is not used during layout. 
android:rowCount The maximum number of rows to create when automatically positioning children. 
android:rowOrderPreserved When set to true, forces row boundaries to appear in the same order as row indices. 
android:useDefaultMargins When set to true, tells GridLayout to use default margins when none are specified in a view's layout parameters. 

Inherited XML attributes

From class android.view.ViewGroup

android:addStatesFromChildren Sets whether this ViewGroup's drawable states also include its children's drawable states. 
android:alwaysDrawnWithCache Defines whether the ViewGroup should always draw its children using their drawing cache or not. 
android:animateLayoutChanges Defines whether changes in layout (caused by adding and removing items) should cause a LayoutTransition to run. 
android:animationCache Defines whether layout animations should create a drawing cache for their children. 
android:clipChildren Defines whether a child is limited to draw inside of its bounds or not. 
android:clipToPadding Defines whether the ViewGroup will clip its children and resize (but not clip) any EdgeEffect to its padding, if padding is not zero. 
android:descendantFocusability Defines the relationship between the ViewGroup and its descendants when looking for a View to take focus. 
android:layoutAnimation Defines the layout animation to use the first time the ViewGroup is laid out. 
android:layoutMode Defines the layout mode of this ViewGroup. 
android:persistentDrawingCache Defines the persistence of the drawing cache. 
android:splitMotionEvents Sets whether this ViewGroup should split MotionEvents to separate child views during touch event dispatch. 

From class android.view.View

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 after which this one is visited in accessibility traversal. 
android:accessibilityTraversalBefore Sets the id of a view before which this one is visited in accessibility traversal. 
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 "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name". 

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: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: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 ALIGN_BOUNDS

This constant is an alignmentMode.

int ALIGN_MARGINS

This constant is an alignmentMode.

int HORIZONTAL

The horizontal orientation.

int UNDEFINED

The constant used to indicate that a value is undefined.

int VERTICAL

The vertical orientation.

Inherited constants

From class android.view.ViewGroup

int CLIP_TO_PADDING_MASK

We clip to padding when FLAG_CLIP_TO_PADDING and FLAG_PADDING_NOT_NULL are set at the same time.

int FOCUS_AFTER_DESCENDANTS

This view will get focus only if none of its descendants want it.

int FOCUS_BEFORE_DESCENDANTS

This view will get focus before any of its descendants.

int FOCUS_BLOCK_DESCENDANTS

This view will block any of its descendants from getting focus, even if they are focusable.

int LAYOUT_MODE_CLIP_BOUNDS

This constant is a layoutMode.

int LAYOUT_MODE_OPTICAL_BOUNDS

This constant is a layoutMode.

int PERSISTENT_ALL_CACHES

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, View.setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call View.draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

int PERSISTENT_ANIMATION_CACHE

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, View.setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call View.draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

int PERSISTENT_NO_CACHE

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, View.setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call View.draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

int PERSISTENT_SCROLLING_CACHE

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, View.setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call View.draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

From class android.view.View

int ACCESSIBILITY_LIVE_REGION_ASSERTIVE

Live region mode specifying that accessibility services should interrupt ongoing speech to immediately announce 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 announce 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 setImportantForAutofill(int)) to a ViewStructure.

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 Date.getTime().

int AUTOFILL_TYPE_LIST

Autofill type for a selection list field, which is filled by an int representing the element index inside the list (starting at 0).

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 CharSequence.

int AUTOFILL_TYPE_TOGGLE

Autofill type for a togglable field, which is filled by a boolean.

int DRAG_FLAG_ACCESSIBILITY_ACTION

Flag indicating that the drag was initiated with AccessibilityNodeInfo.AccessibilityAction#ACTION_DRAG_START.

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 DRAG_FLAG_GLOBAL_URI_READ and/or DRAG_FLAG_GLOBAL_URI_WRITE, the URI permission grant can be persisted across device reboots until explicitly revoked with Context.revokeUriPermission(Uri, int) Context.revokeUriPermission}.

int DRAG_FLAG_GLOBAL_PREFIX_URI_PERMISSION

When this flag is used with DRAG_FLAG_GLOBAL_URI_READ and/or DRAG_FLAG_GLOBAL_URI_WRITE, the URI permission grant applies to any URI that is a prefix match against the original granted URI.

int DRAG_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.

int DRAG_FLAG_GLOBAL_URI_WRITE

When this flag is used with DRAG_FLAG_GLOBAL, the drag recipient will be able to request write access to the content URI(s) contained in the ClipData object.

int DRAG_FLAG_OPAQUE

Flag indicating that the drag shadow will be opaque.

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, setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

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, setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

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, setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

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 addFocusables(java.util.ArrayList, int, int) should add all focusable Views regardless if they are focusable in touch mode.

int FOCUSABLES_TOUCH_MODE

View flag indicating whether addFocusables(java.util.ArrayList, int, int) should add only Views focusable in touch mode.

int FOCUSABLE_AUTO

This view determines focusability automatically.

int FOCUS_BACKWARD

Use with focusSearch(int).

int FOCUS_DOWN

Use with focusSearch(int).

int FOCUS_FORWARD

Use with focusSearch(int).

int FOCUS_LEFT

Use with focusSearch(int).

int FOCUS_RIGHT

Use with focusSearch(int).

int FOCUS_UP

Use with focusSearch(int).

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 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).

int MEASURED_SIZE_MASK

Bits of getMeasuredWidthAndState() and getMeasuredWidthAndState() that provide the actual measured size.

int MEASURED_STATE_MASK

Bits of getMeasuredWidthAndState() and getMeasuredWidthAndState() that provide the additional state bits.

int MEASURED_STATE_TOO_SMALL

Bit of getMeasuredWidthAndState() and getMeasuredWidthAndState() that indicates the measured size is smaller that the space the view would like to have.

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 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 SYSTEM_UI_FLAG_LOW_PROFILE instead.

int STATUS_BAR_VISIBLE

This constant was deprecated in API level 15. Use SYSTEM_UI_FLAG_VISIBLE instead.

int SYSTEM_UI_FLAG_FULLSCREEN

This constant was deprecated in API level 30. Use WindowInsetsController#hide(int) with Type#statusBars() instead.

int SYSTEM_UI_FLAG_HIDE_NAVIGATION

This constant was deprecated in API level 30. Use WindowInsetsController#hide(int) with Type#navigationBars() instead.

int SYSTEM_UI_FLAG_IMMERSIVE

This constant was deprecated in API level 30. Use WindowInsetsController#BEHAVIOR_DEFAULT instead.

int SYSTEM_UI_FLAG_IMMERSIVE_STICKY

This constant was deprecated in API level 30. Use WindowInsetsController#BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE instead.

int SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

This constant was deprecated in API level 30. For floating windows, use LayoutParams#setFitInsetsTypes(int) with Type#statusBars() ()}. For non-floating windows that fill the screen, call Window#setDecorFitsSystemWindows(boolean) with false.

int SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION

This constant was deprecated in API level 30. For floating windows, use LayoutParams#setFitInsetsTypes(int) with Type#navigationBars(). For non-floating windows that fill the screen, call Window#setDecorFitsSystemWindows(boolean) with false.

int SYSTEM_UI_FLAG_LAYOUT_STABLE

This constant was deprecated in API level 30. Use WindowInsets#getInsetsIgnoringVisibility(int) instead to retrieve insets that don't change when system bars change visibility state.

int SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR

This constant was deprecated in API level 30. Use WindowInsetsController#APPEARANCE_LIGHT_NAVIGATION_BARS instead.

int SYSTEM_UI_FLAG_LIGHT_STATUS_BAR

This constant was deprecated in API level 30. Use WindowInsetsController#APPEARANCE_LIGHT_STATUS_BARS instead.

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 WindowInsetsController#hide(int) with Type#systemBars().

int SYSTEM_UI_FLAG_VISIBLE

This constant was deprecated in API level 30. SystemUiVisibility flags are deprecated. Use WindowInsetsController instead.

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 ViewGroup

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 GridLayout.Alignment BASELINE

Indicates that a view should be aligned with the baselines of the other views in its cell group.

public static final GridLayout.Alignment BOTTOM

Indicates that a view should be aligned with the bottom edges of the other views in its cell group.

public static final GridLayout.Alignment CENTER

Indicates that a view should be centered with the other views in its cell group.

public static final GridLayout.Alignment END

Indicates that a view should be aligned with the end edges of the other views in its cell group.

public static final GridLayout.Alignment FILL

Indicates that a view should expanded to fit the boundaries of its cell group.

public static final GridLayout.Alignment LEFT

Indicates that a view should be aligned with the left edges of the other views in its cell group.

public static final GridLayout.Alignment RIGHT

Indicates that a view should be aligned with the right edges of the other views in its cell group.

public static final GridLayout.Alignment START

Indicates that a view should be aligned with the start edges of the other views in its cell group.

public static final GridLayout.Alignment TOP

Indicates that a view should be aligned with the top edges of the other views in its cell group.

Inherited fields

From class android.view.View

public static final Property ALPHA

A Property wrapper around the alpha functionality handled by the View#setAlpha(float) and View#getAlpha() methods.

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 ROTATION

A Property wrapper around the rotation functionality handled by the View#setRotation(float) and View#getRotation() methods.

public static final Property ROTATION_X

A Property wrapper around the rotationX functionality handled by the View#setRotationX(float) and View#getRotationX() methods.

public static final Property ROTATION_Y

A Property wrapper around the rotationY functionality handled by the View#setRotationY(float) and View#getRotationY() methods.

public static final Property SCALE_X

A Property wrapper around the scaleX functionality handled by the View#setScaleX(float) and View#getScaleX() methods.

public static final Property SCALE_Y

A Property wrapper around the scaleY functionality handled by the View#setScaleY(float) and View#getScaleY() methods.

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 TRANSLATION_X

A Property wrapper around the translationX functionality handled by the View#setTranslationX(float) and View#getTranslationX() methods.

public static final Property TRANSLATION_Y

A Property wrapper around the translationY functionality handled by the View#setTranslationY(float) and View#getTranslationY() methods.

public static final Property TRANSLATION_Z

A Property wrapper around the translationZ functionality handled by the View#setTranslationZ(float) and View#getTranslationZ() methods.

protected static final int[] WINDOW_FOCUSED_STATE_SET

Indicates the view's window has focus.

public static final Property X

A Property wrapper around the x functionality handled by the View#setX(float) and View#getX() methods.

public static final Property Y

A Property wrapper around the y functionality handled by the View#setY(float) and View#getY() methods.

public static final Property Z

A Property wrapper around the z functionality handled by the View#setZ(float) and View#getZ() methods.

Public constructors

GridLayout(Context context)
GridLayout(Context context, AttributeSet attrs)
GridLayout(Context context, AttributeSet attrs, int defStyleAttr)
GridLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Public methods

GridLayout.LayoutParams generateLayoutParams(AttributeSet attrs)

Returns a new set of layout parameters based on the supplied attributes set.

CharSequence getAccessibilityClassName()

Return the class name of this object to be used for accessibility purposes.

int getAlignmentMode()

Returns the alignment mode.

int getColumnCount()

Returns the current number of columns.

int getOrientation()

Returns the current orientation.

int getRowCount()

Returns the current number of rows.

boolean getUseDefaultMargins()

Returns whether or not this GridLayout will allocate default margins when no corresponding layout parameters are defined.

boolean isColumnOrderPreserved()

Returns whether or not column boundaries are ordered by their grid indices.

boolean isRowOrderPreserved()

Returns whether or not row boundaries are ordered by their grid indices.

void onViewAdded(View child)

Called when a new child is added to this ViewGroup.

void onViewRemoved(View child)

Called when a child view is removed from this ViewGroup.

void requestLayout()

Call this when something has changed which has invalidated the layout of this view.

void setAlignmentMode(int alignmentMode)

Sets the alignment mode to be used for all of the alignments between the children of this container.

void setColumnCount(int columnCount)

ColumnCount is used only to generate default column/column indices when they are not specified by a component's layout parameters.

void setColumnOrderPreserved(boolean columnOrderPreserved)

When this property is true, GridLayout is forced to place the column boundaries so that their associated grid indices are in ascending order in the view.

void setOrientation(int orientation)

GridLayout uses the orientation property for two purposes:

  • To control the 'direction' in which default row/column indices are generated when they are not specified in a component's layout parameters.
void setRowCount(int rowCount)

RowCount is used only to generate default row/column indices when they are not specified by a component's layout parameters.

void setRowOrderPreserved(boolean rowOrderPreserved)

When this property is true, GridLayout is forced to place the row boundaries so that their associated grid indices are in ascending order in the view.

void setUseDefaultMargins(boolean useDefaultMargins)

When true, GridLayout allocates default margins around children based on the child's visual characteristics.

static GridLayout.Spec spec(int start, float weight)

Equivalent to: spec(start, 1, weight).

static GridLayout.Spec spec(int start)

Return a Spec, spec, where:

  • spec.span = [start, start + 1]

To leave the start index undefined, use the value UNDEFINED.

static GridLayout.Spec spec(int start, int size, GridLayout.Alignment alignment, float weight)

Return a Spec, spec, where:

  • spec.span = [start, start + size]
  • spec.alignment = alignment
  • spec.weight = weight

To leave the start index undefined, use the value UNDEFINED.

static GridLayout.Spec spec(int start, GridLayout.Alignment alignment, float weight)

Equivalent to: spec(start, 1, alignment, weight).

static GridLayout.Spec spec(int start, int size, GridLayout.Alignment alignment)

Equivalent to: spec(start, size, alignment, 0f).

static GridLayout.Spec spec(int start, GridLayout.Alignment alignment)

Return a Spec, spec, where:

  • spec.span = [start, start + 1]
  • spec.alignment = alignment

To leave the start index undefined, use the value UNDEFINED.

static GridLayout.Spec spec(int start, int size, float weight)

Equivalent to: spec(start, 1, default_alignment, weight) - where default_alignment is specified in GridLayout.LayoutParams.

static GridLayout.Spec spec(int start, int size)

Return a Spec, spec, where:

  • spec.span = [start, start + size]

To leave the start index undefined, use the value UNDEFINED.

Protected methods

boolean checkLayoutParams(ViewGroup.LayoutParams p)
GridLayout.LayoutParams generateDefaultLayoutParams()

Returns a set of default layout parameters.

GridLayout.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp)

Returns a safe set of layout parameters based on the supplied layout params.

void onLayout(boolean changed, int left, int top, int right, int bottom)

Called from layout when this view should assign a size and position to each of its children.

void onMeasure(int widthSpec, int heightSpec)

Measure the view and its content to determine the measured width and the measured height.

Inherited methods

From class android.view.ViewGroup

void addChildrenForAccessibility(ArrayList 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 AccessibilityNodeInfo based on an explicit request for the additional data.

void addFocusables(ArrayList 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 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.

boolean addStatesFromChildren()

Returns whether this ViewGroup's drawable states also include its children's drawable states.

void addTouchables(ArrayList views)

Add any touchable views that are descendants of this view (possibly including this view if it is touchable itself) to views.

void addView(View child, ViewGroup.LayoutParams params)

Adds a child view with the specified layout parameters.

void addView(View child, int index)

Adds a child view.

void addView(View child, int index, ViewGroup.LayoutParams params)

Adds a child view with the specified layout parameters.

void addView(View child)

Adds a child view.

void addView(View child, int width, int height)

Adds a child view with this ViewGroup's default layout parameters and the specified width and height.

boolean addViewInLayout(View child, int index, ViewGroup.LayoutParams params, boolean preventRequestLayout)

Adds a view during layout.

boolean addViewInLayout(View child, int index, ViewGroup.LayoutParams params)

Adds a view during layout.

void attachLayoutAnimationParameters(View child, ViewGroup.LayoutParams params, int index, int count)

Subclasses should override this method to set layout animation parameters on the supplied child.

void attachViewToParent(View child, int index, ViewGroup.LayoutParams params)

Attaches a view to this view group.

void bringChildToFront(View child)

Change the z order of the child so it's on top of all other children.

boolean canAnimate()

Indicates whether the view group has the ability to animate its children after the first layout.

boolean checkLayoutParams(ViewGroup.LayoutParams p)
void childDrawableStateChanged(View child)

If addStatesFromChildren() is true, refreshes this group's drawable state (to include the states from its children).

void childHasTransientStateChanged(View child, boolean childHasTransientState)

Called when a child view has changed whether or not it is tracking transient state.

void cleanupLayoutState(View child)

Prevents the specified child to be laid out during the next layout pass.

void clearChildFocus(View child)

Called when a child of this parent is giving up focus

void clearDisappearingChildren()

Removes any pending animations for views that have been removed.

void clearFocus()

Called when this view wants to give up focus.

void debug(int depth)
void detachAllViewsFromParent()

Detaches all views from the parent.

void detachViewFromParent(int index)

Detaches a view from its parent.

void detachViewFromParent(View child)

Detaches a view from its parent.

void detachViewsFromParent(int start, int count)

Detaches a range of views from their parents.

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 viewIds, int[] supportedFormats, TranslationCapability capability, List requests)

Dispatch to collect the ViewTranslationRequests for translation purpose by traversing the hierarchy when the app requests ui translation. The implementation calls dispatchCreateViewTranslationRequest(Map, int[], TranslationCapability, List) for all the child views.

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 dispatchDraw(Canvas canvas)

Called by draw to draw the child views.

void dispatchDrawableHotspotChanged(float x, float y)

Dispatches drawable hotspot changes to child views that meet at least one of the following criteria:

  • Returns false from both View#isClickable() and View#isLongClickable()
  • Requests duplication of parent state via View#setDuplicateParentStateEnabled(boolean)
void dispatchFreezeSelfOnly(SparseArray container)

Perform dispatching of a View.saveHierarchyState(android.util.SparseArray) freeze()} to only this view, not to its children.

boolean dispatchGenericFocusedEvent(MotionEvent event)

Dispatch a generic motion event to the currently focused view.

boolean dispatchGenericPointerEvent(MotionEvent event)

Dispatch a generic motion event to the view under the first pointer.

boolean dispatchHoverEvent(MotionEvent event)

Dispatch a hover 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.

void dispatchPointerCaptureChanged(boolean hasCapture)
void dispatchProvideAutofillStructure(ViewStructure structure, int flags)

Dispatches creation of a ViewStructures for autofill purposes down the hierarchy, when an Assist structure is being created as part of an autofill request.

This implementation adds in all child views of the view group, in addition to calling the default View implementation.

void dispatchProvideStructure(ViewStructure structure)

Dispatch creation of ViewStructure down the hierarchy.

void dispatchRestoreInstanceState(SparseArray container)

Called by restoreHierarchyState(android.util.SparseArray) to retrieve the state for this view and its children.

void dispatchSaveInstanceState(SparseArray container)

Called by saveHierarchyState(android.util.SparseArray) to store the state for this view and its children.

void dispatchScrollCaptureSearch(Rect localVisibleRect, Point windowOffset, Consumer targets)

Handle the scroll capture search request by checking this view if applicable, then to each child view.

void dispatchSetActivated(boolean activated)

Dispatch setActivated to all of this View's children.

void dispatchSetPressed(boolean pressed)

Dispatch setPressed to all of this View's children.

void dispatchSetSelected(boolean selected)

Dispatch setSelected to all of this View's children.

void dispatchSystemUiVisibilityChanged(int visible)

This method is deprecated. Use WindowInsets#isVisible(int) to find out about system bar visibilities by setting a OnApplyWindowInsetsListener on this view.

void dispatchThawSelfOnly(SparseArray container)

Perform dispatching of a View.restoreHierarchyState(android.util.SparseArray) to only this view, not to its children.

boolean dispatchTouchEvent(MotionEvent ev)

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 dispatchVisibilityChanged(View changedView, int visibility)

Dispatch a view visibility change down the view hierarchy.

void dispatchWindowFocusChanged(boolean hasFocus)

Called when the window containing this view gains or loses window focus.

void dispatchWindowInsetsAnimationEnd(WindowInsetsAnimation animation)

Dispatches WindowInsetsAnimation.Callback#onEnd(WindowInsetsAnimation) when Window Insets animation ends.

void dispatchWindowInsetsAnimationPrepare(WindowInsetsAnimation animation)

Dispatches WindowInsetsAnimation.Callback#onPrepare(WindowInsetsAnimation) when Window Insets animation is being prepared.

WindowInsets dispatchWindowInsetsAnimationProgress(WindowInsets insets, List runningAnimations)

Dispatches WindowInsetsAnimation.Callback#onProgress(WindowInsets, List) when Window Insets animation makes progress.

WindowInsetsAnimation.Bounds dispatchWindowInsetsAnimationStart(WindowInsetsAnimation animation, WindowInsetsAnimation.Bounds bounds)

Dispatches WindowInsetsAnimation.Callback#onStart(WindowInsetsAnimation, Bounds) when Window Insets animation is started.

void dispatchWindowSystemUiVisiblityChanged(int visible)

This method is deprecated. SystemUiVisibility flags are deprecated. Use WindowInsetsController instead.

void dispatchWindowVisibilityChanged(int visibility)

Dispatch a window visibility change down the view hierarchy.

boolean drawChild(Canvas canvas, View child, long drawingTime)

Draw one child of this View Group.

void drawableStateChanged()

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

void endViewTransition(View view)

This method should always be called following an earlier call to startViewTransition(android.view.View).

View findFocus()

Find the view in the hierarchy rooted at this view that currently has focus.

OnBackInvokedDispatcher findOnBackInvokedDispatcherForChild(View child, View requester)

Walk up the View hierarchy to find the nearest OnBackInvokedDispatcher.

void findViewsWithText(ArrayList outViews, CharSequence text, int flags)

Finds the Views that contain given text.

View focusSearch(View focused, int direction)

Find the nearest view in the specified direction that wants to take focus.

void focusableViewAvailable(View v)

Tells the parent that a new focusable view has become available.

boolean gatherTransparentRegion(Region region)

This is used by the ViewRoot to perform an optimization when the view hierarchy contains one or several SurfaceView.

ViewGroup.LayoutParams generateDefaultLayoutParams()

Returns a set of default layout parameters.

ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs)

Returns a new set of layout parameters based on the supplied attributes set.

ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)

Returns a safe set of layout parameters based on the supplied layout params.

CharSequence getAccessibilityClassName()

Return the class name of this object to be used for accessibility purposes.

View getChildAt(int index)

Returns the view at the specified position in the group.

int getChildCount()

Returns the number of children in the group.

int getChildDrawingOrder(int childCount, int drawingPosition)

Converts drawing order position to container position.

final int getChildDrawingOrder(int drawingPosition)

Converts drawing order position to container position.

static int getChildMeasureSpec(int spec, int padding, int childDimension)

Does the hard part of measureChildren: figuring out the MeasureSpec to pass to a particular child.

boolean getChildStaticTransformation(View child, Transformation t)

Sets t to be the static transformation of the child, if set, returning a boolean to indicate whether a static transform was set.

boolean getChildVisibleRect(View child, Rect r, Point offset)

Compute the visible part of a rectangular region defined in terms of a child view's coordinates.

boolean getClipChildren()

Returns whether this group's children are clipped to their bounds before drawing.

boolean getClipToPadding()

Returns whether this ViewGroup will clip its children to its padding, and resize (but not clip) any EdgeEffect to the padded region, if padding is present.

int getDescendantFocusability()

Gets the descendant focusability of this view group.

View getFocusedChild()

Returns the focused child of this view, if any.

LayoutAnimationController getLayoutAnimation()

Returns the layout animation controller used to animate the group's children.

Animation.AnimationListener getLayoutAnimationListener()

Returns the animation listener to which layout animation events are sent.

int getLayoutMode()

Returns the basis of alignment during layout operations on this ViewGroup: either LAYOUT_MODE_CLIP_BOUNDS or LAYOUT_MODE_OPTICAL_BOUNDS.

LayoutTransition getLayoutTransition()

Gets the LayoutTransition object for this ViewGroup.

int getNestedScrollAxes()

Return the current axes of nested scrolling for this ViewGroup.

ViewGroupOverlay getOverlay()

Returns the ViewGroupOverlay for this view group, creating it if it does not yet exist.

int getPersistentDrawingCache()

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, View.setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call View.draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

boolean getTouchscreenBlocksFocus()

Check whether this ViewGroup should ignore focus requests for itself and its children.

boolean hasFocus()

Returns true if this view has or contains focus

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.

int indexOfChild(View child)

Returns the position in the group of the specified child view.

final void invalidateChild(View child, Rect dirty)

This method is deprecated. Use onDescendantInvalidated(android.view.View, android.view.View) instead to observe updates to draw state in descendants.

ViewParent invalidateChildInParent(int[] location, Rect dirty)

This method is deprecated. Use onDescendantInvalidated(android.view.View, android.view.View) instead to observe updates to draw state in descendants.

boolean isAlwaysDrawnWithCacheEnabled()

This method was deprecated in API level 23. As of Build.VERSION_CODES.M, this property is ignored. Child views may no longer have their caching behavior disabled by parents.

boolean isAnimationCacheEnabled()

This method was deprecated in API level 23. As of Build.VERSION_CODES.M, this property is ignored. Caching behavior of children may be controlled through View#setLayerType(int, Paint).

boolean isChildrenDrawingOrderEnabled()

Indicates whether the ViewGroup is drawing its children in the order defined by getChildDrawingOrder(int, int).

boolean isChildrenDrawnWithCacheEnabled()

This method was deprecated in API level 23. As of Build.VERSION_CODES.M, this property is ignored. Child views may no longer be forced to cache their rendering state by their parents. Use View#setLayerType(int, Paint) on individual Views instead.

boolean isLayoutSuppressed()

Returns whether layout calls on this container are currently being suppressed, due to an earlier call to suppressLayout(boolean).

boolean isMotionEventSplittingEnabled()

Returns true if MotionEvents dispatched to this ViewGroup can be split to multiple children.

boolean isTransitionGroup()

Returns true if this ViewGroup should be considered as a single entity for removal when executing an Activity transition.

void jumpDrawablesToCurrentState()

Call Drawable.jumpToCurrentState() on all Drawable objects associated with this view.

final 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.

void measureChild(View child, int parentWidthMeasureSpec, int parentHeightMeasureSpec)

Ask one of the children of this view to measure itself, taking into account both the MeasureSpec requirements for this view and its padding.

void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed)

Ask one of the children of this view to measure itself, taking into account both the MeasureSpec requirements for this view and its padding and margins.

void measureChildren(int widthMeasureSpec, int heightMeasureSpec)

Ask all of the children of this view to measure themselves, taking into account both the MeasureSpec requirements for this view and its padding.

void notifySubtreeAccessibilityStateChanged(View child, View source, int changeType)

Notifies a view parent that the accessibility state of one of its descendants has changed and that the structure of the subtree is different.

final void offsetDescendantRectToMyCoords(View descendant, Rect rect)

Offset a rectangle that is in a descendant's coordinate space into our coordinate space.

final void offsetRectIntoDescendantCoords(View descendant, Rect rect)

Offset a rectangle that is in our coordinate space into an ancestor's coordinate space.

void onAttachedToWindow()

This is called when the view is attached to a window.

int[] onCreateDrawableState(int extraSpace)

Generate the new Drawable state for this view.

void onDescendantInvalidated(View child, View target)

The target View has been invalidated, or has had a drawing property changed that requires the hierarchy to re-render. If you override this method you must call through to the superclass implementation.

void onDetachedFromWindow()

This is called when the view is detached from a window.

boolean onInterceptHoverEvent(MotionEvent event)

Implement this method to intercept hover events before they are handled by child views.

boolean onInterceptTouchEvent(MotionEvent ev)

Implement this method to intercept all touch screen motion events.

abstract void onLayout(boolean changed, int l, int t, int r, int b)

Called from layout when this view should assign a size and position to each of its children.

boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed)

Request a fling from a nested scroll.

boolean onNestedPreFling(View target, float velocityX, float velocityY)

React to a nested fling before the target view consumes it.

boolean onNestedPrePerformAccessibilityAction(View target, int action, Bundle args)

React to an accessibility action delegated by a target descendant view before the target processes it.

Subclasses should always call super.onNestedPrePerformAccessibilityAction

void onNestedPreScroll(View target, int dx, int dy, int[] consumed)

React to a nested scroll in progress before the target view consumes a portion of the scroll.

void onNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed)

React to a nested scroll in progress.

void onNestedScrollAccepted(View child, View target, int axes)

React to the successful claiming of a nested scroll operation.

boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect)

Look for a descendant to call View#requestFocus on.

boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event)

Called when a child has requested sending an AccessibilityEvent and gives an opportunity to its parent to augment the event.

PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex)

Returns the pointer icon for the motion event, or null if it doesn't specify the icon.

boolean onStartNestedScroll(View child, View target, int nestedScrollAxes)

React to a descendant view initiating a nestable scroll operation, claiming the nested scroll operation if appropriate.

void onStopNestedScroll(View child)

React to a nested scroll operation ending.

void onViewAdded(View child)

Called when a new child is added to this ViewGroup.

void onViewRemoved(View child)

Called when a child view is removed from this ViewGroup.

void recomputeViewAttributes(View child)

Tell view hierarchy that the global view attributes need to be re-evaluated.

void removeAllViews()

Call this method to remove all child views from the ViewGroup.

void removeAllViewsInLayout()

Called by a ViewGroup subclass to remove child views from itself, when it must first know its size on screen before it can calculate how many child views it will render.

void removeDetachedView(View child, boolean animate)

Finishes the removal of a detached view.

void removeView(View view)

Note: do not invoke this method from View.draw(android.graphics.Canvas), View.onDraw(android.graphics.Canvas), dispatchDraw(android.graphics.Canvas) or any related method.

void removeViewAt(int index)

Removes the view at the specified position in the group.

void removeViewInLayout(View view)

Removes a view during layout.

void removeViews(int start, int count)

Removes the specified range of views from the group.

void removeViewsInLayout(int start, int count)

Removes a range of views during layout.

void requestChildFocus(View child, View focused)

Called when a child of this parent wants focus

boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate)

Called when a child of this group wants a particular rectangle to be positioned onto the screen.

void requestDisallowInterceptTouchEvent(boolean disallowIntercept)

Called when a child does not want this parent and its ancestors to intercept touch events with ViewGroup#onInterceptTouchEvent(MotionEvent).

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. Looks for a view to give focus to respecting the setting specified by getDescendantFocusability().

boolean requestSendAccessibilityEvent(View child, AccessibilityEvent event)

Called by a child to request from its parent to send an AccessibilityEvent.

void requestTransparentRegion(View child)

Called when a child wants the view hierarchy to gather and report transparent regions to the window compositor.

boolean restoreDefaultFocus()

Gives focus to the default-focus view in the view hierarchy that has this view as a root.

void scheduleLayoutAnimation()

Schedules the layout animation to be played after the next layout pass of this view group.

void setAddStatesFromChildren(boolean addsStates)

Sets whether this ViewGroup's drawable states also include its children's drawable states.

void setAlwaysDrawnWithCacheEnabled(boolean always)

This method was deprecated in API level 23. As of Build.VERSION_CODES.M, this property is ignored. Child views may no longer have their caching behavior disabled by parents.

void setAnimationCacheEnabled(boolean enabled)

This method was deprecated in API level 23. As of Build.VERSION_CODES.M, this property is ignored. Caching behavior of children may be controlled through View#setLayerType(int, Paint).

void setChildrenDrawingCacheEnabled(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, View.setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call View.draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

void setChildrenDrawingOrderEnabled(boolean enabled)

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

void setChildrenDrawnWithCacheEnabled(boolean enabled)

This method was deprecated in API level 23. As of Build.VERSION_CODES.M, this property is ignored. Child views may no longer be forced to cache their rendering state by their parents. Use View#setLayerType(int, Paint) on individual Views instead.

void setClipChildren(boolean clipChildren)

By default, children are clipped to their bounds before drawing.

void setClipToPadding(boolean clipToPadding)

Sets whether this ViewGroup will clip its children to its padding and resize (but not clip) any EdgeEffect to the padded region, if padding is present.

void setDescendantFocusability(int focusability)

Set the descendant focusability of this view group.

void setLayoutAnimation(LayoutAnimationController controller)

Sets the layout animation controller used to animate the group's children after the first layout.

void setLayoutAnimationListener(Animation.AnimationListener animationListener)

Specifies the animation listener to which layout animation events must be sent.

void setLayoutMode(int layoutMode)

Sets the basis of alignment during the layout of this ViewGroup.

void setLayoutTransition(LayoutTransition transition)

Sets the LayoutTransition object for this ViewGroup.

void setMotionEventSplittingEnabled(boolean split)

Enable or disable the splitting of MotionEvents to multiple children during touch event dispatch.

void setOnHierarchyChangeListener(ViewGroup.OnHierarchyChangeListener listener)

Register a callback to be invoked when a child is added to or removed from this view.

void setPersistentDrawingCache(int drawingCacheToKeep)

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, View.setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call View.draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

void setStaticTransformationsEnabled(boolean enabled)

When this property is set to true, this ViewGroup supports static transformations on children; this causes getChildStaticTransformation(android.view.View, android.view.animation.Transformation) to be invoked when a child is drawn.

void setTouchscreenBlocksFocus(boolean touchscreenBlocksFocus)

Set whether this ViewGroup should ignore focus requests for itself and its children.

void setTransitionGroup(boolean isTransitionGroup)

Changes whether or not this ViewGroup should be treated as a single entity during Activity Transitions.

void setWindowInsetsAnimationCallback(WindowInsetsAnimation.Callback callback)

Sets a WindowInsetsAnimation.Callback to be notified about animations of windows that cause insets.

boolean shouldDelayChildPressedState()

Return true if the pressed state should be delayed for children or descendants of this ViewGroup.

boolean showContextMenuForChild(View originalView, float x, float y)

Shows the context menu for the specified view or its ancestors anchored to the specified view-relative coordinate.

boolean showContextMenuForChild(View originalView)

Shows the context menu for the specified view or its ancestors.

ActionMode startActionModeForChild(View originalView, ActionMode.Callback callback, int type)

Start an action mode of a specific type for the specified view.

ActionMode startActionModeForChild(View originalView, ActionMode.Callback callback)

Start an action mode for the specified view with the default type ActionMode#TYPE_PRIMARY.

void startLayoutAnimation()

Runs the layout animation.

void startViewTransition(View view)

This method tells the ViewGroup that the given View object, which should have this ViewGroup as its parent, should be kept around (re-displayed when the ViewGroup draws its children) even if it is removed from its parent.

void suppressLayout(boolean suppress)

Tells this ViewGroup to suppress all layout() calls until layout suppression is disabled with a later call to suppressLayout(false).

void updateViewLayout(View view, ViewGroup.LayoutParams params)

From class android.view.View

void addChildrenForAccessibility(ArrayList 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 AccessibilityNodeInfo based on an explicit request for the additional data.

void addFocusables(ArrayList 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 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 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 KeyEvents.

void addTouchables(ArrayList 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)

Convenience method for sending a AccessibilityEvent#TYPE_ANNOUNCEMENT AccessibilityEvent to suggest that an accessibility service announce the specified text to its users.

void autofill(AutofillValue value)

Automatically fills the content of this view with the value.

void autofill(SparseArray values)

Automatically fills the content of the virtual children within this view.

boolean awakenScrollBars(int startDelay, boolean invalidate)

Trigger the scrollbars to draw.

boolean awakenScrollBars(int startDelay)

Trigger the scrollbars to draw.

boolean awakenScrollBars()

Trigger the scrollbars to draw.

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, setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

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, setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

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 InputMethodManager when a view who is not the current input connection target is trying to make a call on the manager.

void clearAnimation()

Cancels any animations for this view.

void clearFocus()

Called when this view wants to give up focus.

void clearViewTranslationCallback()

Clear the ViewTranslationCallback from this view.

static int combineMeasuredStates(int curState, int newState)

Merge two states as returned by getMeasuredState().

int computeHorizontalScrollExtent()

Compute the horizontal extent of the horizontal scrollbar's thumb within the horizontal range.

int computeHorizontalScrollOffset()

Compute the horizontal offset of the horizontal scrollbar's thumb within the horizontal range.

int computeHorizontalScrollRange()

Compute the horizontal range that the horizontal scrollbar represents.

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.

int computeVerticalScrollExtent()

Compute the vertical extent of the vertical scrollbar's thumb within the vertical range.

int computeVerticalScrollOffset()

Compute the vertical offset of the vertical scrollbar's thumb within the horizontal range.

int computeVerticalScrollRange()

Compute the vertical range that the vertical scrollbar represents.

AccessibilityNodeInfo createAccessibilityNodeInfo()

Returns an AccessibilityNodeInfo representing this view from the point of view of an AccessibilityService.

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, setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

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 viewIds, int[] supportedFormats, TranslationCapability capability, List requests)

Dispatch to collect the ViewTranslationRequests for translation purpose by traversing the hierarchy when the app requests ui translation.

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 dispatchDraw(Canvas canvas)

Called by draw to draw the child views.

void dispatchDrawableHotspotChanged(float x, float y)

Dispatches drawableHotspotChanged to all of this View's children.

void dispatchFinishTemporaryDetach()

Dispatch onFinishTemporaryDetach() to this View and its direct children if this is a container View.

boolean dispatchGenericFocusedEvent(MotionEvent event)

Dispatch a generic motion event to the currently focused view.

boolean dispatchGenericMotionEvent(MotionEvent event)

Dispatch a generic motion event.

boolean dispatchGenericPointerEvent(MotionEvent event)

Dispatch a generic motion event to the view under the first pointer.

boolean dispatchHoverEvent(MotionEvent event)

Dispatch a hover 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 AccessibilityEvent to the View first and then to its children for adding their text content to the event.

void dispatchProvideAutofillStructure(ViewStructure structure, int flags)

Dispatches creation of a ViewStructures for autofill purposes down the hierarchy, when an Assist structure is being created as part of an autofill request.

void dispatchProvideStructure(ViewStructure structure)

Dispatch creation of ViewStructure down the hierarchy.

void dispatchRestoreInstanceState(SparseArray container)

Called by restoreHierarchyState(android.util.SparseArray) to retrieve the state for this view and its children.

void dispatchSaveInstanceState(SparseArray container)

Called by saveHierarchyState(android.util.SparseArray) to store the state for this view and its children.

void dispatchScrollCaptureSearch(Rect localVisibleRect, Point windowOffset, Consumer targets)

Dispatch a scroll capture search request down the view hierarchy.

void dispatchSetActivated(boolean activated)

Dispatch setActivated to all of this View's children.

void dispatchSetPressed(boolean pressed)

Dispatch setPressed to all of this View's children.

void dispatchSetSelected(boolean selected)

Dispatch setSelected to all of this View's children.

void dispatchStartTemporaryDetach()

Dispatch onStartTemporaryDetach() to this View and its direct children if this is a container View.

void dispatchSystemUiVisibilityChanged(int visibility)

This method was deprecated in API level 30. Use WindowInsets#isVisible(int) to find out about system bar visibilities by setting a OnApplyWindowInsetsListener on this view.

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 dispatchVisibilityChanged(View changedView, int visibility)

Dispatch a view visibility change down the view hierarchy.

void dispatchWindowFocusChanged(boolean hasFocus)

Called when the window containing this view gains or loses window focus.

void dispatchWindowInsetsAnimationEnd(WindowInsetsAnimation animation)

Dispatches WindowInsetsAnimation.Callback#onEnd(WindowInsetsAnimation) when Window Insets animation ends.

void dispatchWindowInsetsAnimationPrepare(WindowInsetsAnimation animation)

Dispatches WindowInsetsAnimation.Callback#onPrepare(WindowInsetsAnimation) when Window Insets animation is being prepared.

WindowInsets dispatchWindowInsetsAnimationProgress(WindowInsets insets, List runningAnimations)

Dispatches WindowInsetsAnimation.Callback#onProgress(WindowInsets, List) when Window Insets animation makes progress.

WindowInsetsAnimation.Bounds dispatchWindowInsetsAnimationStart(WindowInsetsAnimation animation, WindowInsetsAnimation.Bounds bounds)

Dispatches WindowInsetsAnimation.Callback#onStart(WindowInsetsAnimation, Bounds) when Window Insets animation is started.

void dispatchWindowSystemUiVisiblityChanged(int visible)

This method was deprecated in API level 30. SystemUiVisibility flags are deprecated. Use WindowInsetsController instead.

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.

void drawableStateChanged()

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

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 OnBackInvokedDispatcher.

final T findViewById(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.

final T findViewWithTag(Object tag)

Look for a child view with the given tag.

void findViewsWithText(ArrayList outViews, CharSequence searched, int flags)

Finds the Views that contain given text.

boolean fitSystemWindows(Rect insets)

This method was deprecated in API level 20. As of API 20 use dispatchApplyWindowInsets(android.view.WindowInsets) to apply insets to views. Views should override onApplyWindowInsets(android.view.WindowInsets) or use setOnApplyWindowInsetsListener(android.view.View.OnApplyWindowInsetsListener) to implement handling their own insets.

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 hasOverlappingRendering() for more details on this behavior).

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 DisplayHash for this view.

static int generateViewId()

Generate a value suitable for use in setId(int).

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 AccessibilityServices that explore the window content.

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.

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 View.

Map 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 AutofillService determine how to autofill the view with the user's data.

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 AutofillService can create the proper AutofillValue when autofilling the view.

AutofillValue getAutofillValue()

Gets the View's current autofill value.

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 getBottomFadingEdgeStrength()

Returns the strength, or intensity, of the bottom faded edge.

int getBottomPaddingOffset()

Amount by which to extend the bottom fading region.

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 true if successful or false if the view's clip bounds are null.

Rect getClipBounds()

Returns a copy of the current clipBounds.

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 View's content description.

final Context getContext()

Returns the context the view is running in, through which it can access the current theme, resources, etc.

ContextMenu.ContextMenuInfo getContextMenuInfo()

Views should implement this if they have extra information to associate with the context menu.

final boolean getDefaultFocusHighlightEnabled()

Returns 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.

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, setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

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, setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

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, setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

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, setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

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 style="..." in the AttributeSet's backing XML element or Resources#ID_NULL otherwise if not specified or otherwise not applicable.

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 setFitsSystemWindows(boolean).

int getFocusable()

Returns the focusable setting for this view.

ArrayList 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.

final boolean getGlobalVisibleRect(Rect r)

Sets r to the coordinates of the non-clipped area of this view in the coordinate space of the view's root view.

boolean getGlobalVisibleRect(Rect r, Point globalOffset)

Sets r to the coordinates of the non-clipped area of this view in the coordinate space of the view's root view.

Handler getHandler()
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.

int getHorizontalScrollbarHeight()

Returns the height of the horizontal scrollbar.

Drawable getHorizontalScrollbarThumbDrawable()

Returns the currently configured Drawable for the thumb of the horizontal scroll bar if it exists, null otherwise.

Drawable getHorizontalScrollbarTrackDrawable()

Returns the currently configured Drawable for the track of the horizontal scroll bar if it exists, null otherwise.

int getId()

Returns this view's identifier.

int getImportantForAccessibility()

Gets the mode for determining whether this View is important for accessibility.

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 KEEP_SCREEN_ON.

KeyEvent.DispatcherState getKeyDispatcherState()

Return the global KeyEvent.DispatcherState for this view's window.

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.

float getLeftFadingEdgeStrength()

Returns the strength, or intensity, of the left faded edge.

int getLeftPaddingOffset()

Amount by which to extend the left fading region.

final boolean getLocalVisibleRect(Rect r)

Sets r to the coordinates of the non-clipped area of this view relative to the top left corner of the view.

void getLocationInSurface(int[] location)

Gets the coordinates of this view in the coordinate space of the Surface that contains the view.

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 getMeasuredHeightAndState(), but only returns the raw height component (that is the result is masked by MEASURED_SIZE_MASK).

final int getMeasuredHeightAndState()

Return the full height measurement information for this view as computed by the most recent call to measure(int, int).

final int getMeasuredState()

Return only the state bits of getMeasuredWidthAndState() and getMeasuredHeightAndState(), combined into one integer.

final int getMeasuredWidth()

Like getMeasuredWidthAndState(), but only returns the raw width component (that is the result is masked by MEASURED_SIZE_MASK).

final int getMeasuredWidthAndState()

Return the full width measurement information for this view as computed by the most recent call to measure(int, int).

int getMinimumHeight()

Returns the minimum height of the view.

int getMinimumWidth()

Returns the minimum width of the view.

int getNextClusterForwardId()

Gets the id of the root of the next keyboard navigation cluster.

int getNextFocusDownId()

Gets the id of the view to use when the next focus is FOCUS_DOWN.

int getNextFocusForwardId()

Gets the id of the view to use when the next focus is FOCUS_FORWARD.

int getNextFocusLeftId()

Gets the id of the view to use when the next focus is FOCUS_LEFT.

int getNextFocusRightId()

Gets the id of the view to use when the next focus is FOCUS_RIGHT.

int getNextFocusUpId()

Gets the id of the view to use when the next focus is FOCUS_UP.

View.OnFocusChangeListener getOnFocusChangeListener()

Returns the focus-change callback registered for this view.

int getOutlineAmbientShadowColor()
ViewOutlineProvider getOutlineProvider()

Returns the current ViewOutlineProvider of the view, which generates the Outline that defines the shape of the shadow it casts, and enables outline clipping.

int getOutlineSpotShadowColor()
int getOverScrollMode()

Returns the over-scroll mode for this view.

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.

float getPivotX()

The x location of the point around which the view is rotated and scaled.

float getPivotY()

The y location of the point around which the view is rotated and scaled.

PointerIcon getPointerIcon()

Gets the pointer icon for the current view.

final List getPreferKeepClearRects()
String[] getReceiveContentMimeTypes()

Returns the MIME types accepted by performReceiveContent(ContentInfo) for this view, as configured via setOnReceiveContentListener(String[], OnReceiveContentListener).

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.

float getRightFadingEdgeStrength()

Returns the strength, or intensity, of the right faded edge.

int getRightPaddingOffset()

Amount by which to extend the right fading region.

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 View can be inflated from an XML layout.

final CharSequence getStateDescription()

Returns the View's state description.

StateListAnimator getStateListAnimator()

Returns the current StateListAnimator if exists.

int getSuggestedMinimumHeight()

Returns the suggested minimum height that the view should use.

int getSuggestedMinimumWidth()

Returns the suggested minimum width that the view should use.

List 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 WindowInsetsController instead.

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.

float getTopFadingEdgeStrength()

Returns the strength, or intensity, of the top faded edge.

int getTopPaddingOffset()

Amount by which to extend the top fading region.

TouchDelegate getTouchDelegate()

Gets the TouchDelegate for this View.

ArrayList 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 left position.

float getTranslationY()

The vertical location of this view relative to its top position.

float getTranslationZ()

The depth location of this view relative to its elevation.

long getUniqueDrawingId()

Get the identifier used for this view by the drawing system.

int getVerticalFadingEdgeLength()

Returns the size of the vertical faded edges used to indicate that more content in this view is visible.

int getVerticalScrollbarPosition()
Drawable getVerticalScrollbarThumbDrawable()

Returns the currently configured Drawable for the thumb of the vertical scroll bar if it exists, null otherwise.

Drawable getVerticalScrollbarTrackDrawable()

Returns the currently configured Drawable for the track of the vertical scroll bar if it exists, null otherwise.

int getVerticalScrollbarWidth()

Returns the width of the vertical scrollbar.

ViewTranslationResponse getViewTranslationResponse()

Returns the ViewTranslationResponse associated with this view.

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.

int getWindowAttachCount()
WindowId getWindowId()

Retrieve the WindowId for the window this view is currently attached to.

WindowInsetsController getWindowInsetsController()

Retrieves the single WindowInsetsController of the window this view is attached to.

int getWindowSystemUiVisibility()

This method was deprecated in API level 30. SystemUiVisibility flags are deprecated. Use WindowInsetsController instead.

IBinder getWindowToken()

Retrieve a unique token identifying the window this view is attached to.

int getWindowVisibility()

Returns the current visibility of the window this view is attached to (either GONE, INVISIBLE, or VISIBLE).

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 hasExplicitFocusable() returns true.

boolean hasFocus()

Returns true if this view has focus itself, or is the ancestor of the view that has focus.

boolean hasFocusable()

Returns true if this view is focusable or if it contains a reachable View for which hasFocusable() returns true.

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 invalidate().

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 invalidate().

void invalidateDrawable(Drawable drawable)

Invalidates the specified Drawable.

void invalidateOutline()

Called to rebuild this View's Outline from its outline provider

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.

boolean isContextClickable()

Indicates whether this view reacts to context clicks or not.

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, setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

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()

See setForceDarkAllowed(boolean)

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 AssistStructure.ViewNode associated with this view is considered important for autofill purposes.

final boolean isImportantForContentCapture()

Hints the Android System whether this view is considered important for content capture, based on the value explicitly set by setImportantForContentCapture(int) and heuristics when it's IMPORTANT_FOR_CONTENT_CAPTURE_AUTO.

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 whether the device is currently in touch mode.

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 isPaddingOffsetRequired()

If the View draws content inside its padding and enables fading edges, it needs to support padding offsets.

boolean isPaddingRelative()

Return if the padding has been set through relative values setPaddingRelative(int, int, int, int) or through

boolean isPivotSet()

Returns whether or not a pivot has been set by a call to setPivotX(float) or setPivotY(float).

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 onSaveInstanceState() method will be called).

boolean isSaveFromParentEnabled()

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

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 true when the View is attached and the system developer setting to show the layout bounds is enabled or false otherwise.

boolean isShown()

Returns the visibility of this view and all of its ancestors

boolean isSoundEffectsEnabled()
final boolean isTemporarilyDetached()

Tells whether the View is in the state between onStartTemporaryDetach() and onFinishTemporaryDetach().

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

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.

static int[] mergeDrawableStates(int[] baseState, int[] additionalState)

Merge your own state values in additionalState into the base state values baseState that were returned by onCreateDrawableState(int).

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.

void onAnimationEnd()

Invoked by a parent ViewGroup to notify the end of the animation currently associated with this view.

void onAnimationStart()

Invoked by a parent ViewGroup to notify the start of the animation currently associated with this view.

WindowInsets onApplyWindowInsets(WindowInsets insets)

Called when the view should apply WindowInsets according to its internal policy.

void onAttachedToWindow()

This is called when the view is attached to a window.

void onCancelPendingInputEvents()

Called as the result of a call to cancelPendingInputEvents() on this view or a parent view.

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.

void onConfigurationChanged(Configuration newConfig)

Called when the current configuration of the resources being used by the application have changed.

void onCreateContextMenu(ContextMenu menu)

Views should implement this if the view itself is going to add items to the context menu.

int[] onCreateDrawableState(int extraSpace)

Generate the new Drawable state for this view.

InputConnection onCreateInputConnection(EditorInfo outAttrs)

Create a new InputConnection for an InputMethod to interact with the view.

void onCreateViewTranslationRequest(int[] supportedFormats, Consumer requestsCollector)

Collects a ViewTranslationRequest which represents the content to be translated in the view.

void onCreateVirtualViewTranslationRequests(long[] virtualIds, int[] supportedFormats, Consumer requestsCollector)

Collects ViewTranslationRequests which represents the content to be translated for the virtual views in the host view.

void onDetachedFromWindow()

This is called when the view is detached from a window.

void onDisplayHint(int hint)

Gives this view a hint about whether is displayed or not.

boolean onDragEvent(DragEvent event)

Handles drag events sent by the system following a call to startDragAndDrop().

void onDraw(Canvas canvas)

Implement this to do your drawing.

void onDrawForeground(Canvas canvas)

Draw any foreground content for this view.

final void onDrawScrollBars(Canvas canvas)

Request the drawing of the horizontal and the vertical scrollbar.

boolean onFilterTouchEventForSecurity(MotionEvent event)

Filter the touch event to apply security policies.

void onFinishInflate()

Finalize inflating a view from XML.

void onFinishTemporaryDetach()

Called after onStartTemporaryDetach() when the container is done changing the view.

void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect)

Called by the view system when the focus state of this view changes.

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 AccessibilityEvent with information about this View which is the event source.

void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)

Initializes an AccessibilityNodeInfo with information about this view.

boolean onKeyDown(int keyCode, KeyEvent event)

Default implementation of KeyEvent.Callback.onKeyDown(): perform press of the view when KeyEvent#KEYCODE_DPAD_CENTER or KeyEvent#KEYCODE_ENTER is released, if the view is enabled and clickable.

boolean onKeyLongPress(int keyCode, KeyEvent event)

Default implementation of KeyEvent.Callback.onKeyLongPress(): always returns false (doesn't handle the event).

boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event)

Default implementation of KeyEvent.Callback.onKeyMultiple(): always returns false (doesn't handle the event).

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 KeyEvent.Callback.onKeyUp(): perform clicking of the view when KeyEvent#KEYCODE_DPAD_CENTER, KeyEvent#KEYCODE_ENTER or KeyEvent#KEYCODE_SPACE is released.

void onLayout(boolean changed, int left, int top, int right, int bottom)

Called from layout when this view should assign a size and position to each of its children.

void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height.

void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY)

Called by overScrollBy(int, int, int, int, int, int, int, int, boolean) to respond to the results of an over-scroll operation.

void onPointerCaptureChange(boolean hasCapture)

Called when the window has just acquired or lost pointer capture.

void onPopulateAccessibilityEvent(AccessibilityEvent event)

Called from dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent) giving a chance to this View to populate the accessibility event with its text content.

void onProvideAutofillStructure(ViewStructure structure, int flags)

Populates a ViewStructure to fullfil an autofill request.

void onProvideAutofillVirtualStructure(ViewStructure structure, int flags)

Populates a ViewStructure containing virtual children to fullfil an autofill request.

void onProvideContentCaptureStructure(ViewStructure structure, int flags)

Populates a ViewStructure for content capture.

void onProvideStructure(ViewStructure structure)

Called when assist structure is being retrieved from a view as part of Activity.onProvideAssistData.

void onProvideVirtualStructure(ViewStructure structure)

Called when assist structure is being retrieved from a view as part of Activity.onProvideAssistData to generate additional virtual structure under this view.

ContentInfo onReceiveContent(ContentInfo payload)

Implements the default behavior for receiving content for this type of view.

PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex)

Returns the pointer icon for the motion event, or null if it doesn't specify the icon.

void onRestoreInstanceState(Parcelable state)

Hook allowing a view to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState().

void onRtlPropertiesChanged(int layoutDirection)

Called when any RTL property (layout direction or text direction or text alignment) has been changed.

Parcelable onSaveInstanceState()

Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state.

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 targets)

Called when scroll capture is requested, to search for appropriate content to scroll.

void onScrollChanged(int l, int t, int oldl, int oldt)

This is called in response to an internal scroll in this view (i.e., the view scrolled its own contents).

boolean onSetAlpha(int alpha)

Invoked if there is a Transform that involves alpha.

void onSizeChanged(int w, int h, int oldw, int oldh)

This is called during layout when the size of this view has changed.

void onStartTemporaryDetach()

This is called when a container is going to temporarily detach a child, with ViewGroup.detachViewFromParent.

boolean onTouchEvent(MotionEvent event)

Implement this method to handle touch screen motion events.

boolean onTrackballEvent(MotionEvent event)

Implement this method to handle trackball motion events.

void onViewTranslationResponse(ViewTranslationResponse response)

Called when the content from View#onCreateViewTranslationRequest had been translated by the TranslationService.

void onVirtualViewTranslationResponses(LongSparseArray response)

Called when the content from View#onCreateVirtualViewTranslationRequests had been translated by the TranslationService.

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 onVisibilityChanged(View changedView, int visibility)

Called when the visibility of the view or an ancestor of the view has changed.

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 WindowInsetsController instead.

void onWindowVisibilityChanged(int visibility)

Called when the window containing has change its visibility (between GONE, INVISIBLE, and VISIBLE).

boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent)

Scroll the view with standard behavior for scrolling beyond the normal content boundaries.

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(int feedbackConstant, int flags)

BZZZTT!!1!

Like performHapticFeedback(int), with additional options.

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 KeyEvents.

void requestApplyInsets()

Ask that a new dispatch of onApplyWindowInsets(android.view.WindowInsets) be performed.

void requestFitSystemWindows()

This method was deprecated in API level 20. Use requestApplyInsets() for newer platform versions.

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)

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 requireViewById(int id)

Finds the first descendant view with the given ID, the view itself if the ID matches getId(), or throws an IllegalArgumentException if the ID is invalid or there is no matching view in the hierarchy.

void resetPivot()

Clears any pivot previously set by a call to setPivotX(float) or setPivotY(float).

static int resolveSize(int size, int measureSpec)

Version of resolveSizeAndState(int, int, int) returning only the MEASURED_SIZE_MASK bits of the result.

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 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 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 sendAccessibilityEvent(int) but takes as an argument an empty AccessibilityEvent and does not perform a check whether accessibility is enabled.

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 after which this one is visited in accessibility traversal.

void setAccessibilityTraversalBefore(int beforeId)

Sets the id of a view before which this one is visited in accessibility traversal.

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 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 AutofillService determine how to autofill the view with the user's data.

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 setBackground(android.graphics.drawable.Drawable) instead

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 setBackgroundTintList(android.content.res.ColorStateList)} to the background drawable.

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 setBackgroundTintList(android.content.res.ColorStateList)} to the background drawable.

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) ContentCaptureSession associated with this view.

void setContentDescription(CharSequence contentDescription)

Sets the View's content description.

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 R.attr.state_focused defined in its background.

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, setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

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, setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

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, setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

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 fitSystemWindows(android.graphics.Rect) will be executed.

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 setForegroundTintList(android.content.res.ColorStateList)} to the background drawable.

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 setForegroundTintList(android.content.res.ColorStateList)} to the background drawable.

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 setKeepScreenOn(boolean keepScreenOn)

Controls whether the screen should remain on, modifying the value of KEEP_SCREEN_ON.

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 Paint object used with the current layer (used only if the current layer type is not set to LAYER_TYPE_NONE).

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.

final void setMeasuredDimension(int measuredWidth, int measuredHeight)

This method must be called by onMeasure(int, int) to store the measured width and measured height.

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 FOCUS_DOWN.

void setNextFocusForwardId(int nextFocusForwardId)

Sets the id of the view to use when the next focus is FOCUS_FORWARD.

void setNextFocusLeftId(int nextFocusLeftId)

Sets the id of the view to use when the next focus is FOCUS_LEFT.

void setNextFocusRightId(int nextFocusRightId)

Sets the id of the view to use when the next focus is FOCUS_RIGHT.

void setNextFocusUpId(int nextFocusUpId)

Sets the id of the view to use when the next focus is FOCUS_UP.

void setOnApplyWindowInsetsListener(View.OnApplyWindowInsetsListener listener)

Set an OnApplyWindowInsetsListener to take over the policy for applying window insets to this view.

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 used to handle insertion of content into this view.

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 WindowInsets#isVisible(int) to find out about system bar visibilities by setting a OnApplyWindowInsetsListener on this view.

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 ViewOutlineProvider of the view, which generates the Outline that defines the shape of the shadow it casts, and enables outline clipping.

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 setPivotX(float pivotX)

Sets the x location of the point around which the view is rotated and scaled.

void setPivotY(float pivotY)

Sets the y location of the point around which the view is rotated and scaled.

void setPointerIcon(PointerIcon pointerIcon)

Set the pointer icon for 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 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 RenderEffect to apply to this View.

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 onSaveInstanceState() method will be called).

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 View's state description.

void setStateListAnimator(StateListAnimator stateListAnimator)

Attaches the provided StateListAnimator to this View.

void setSystemGestureExclusionRects(List 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 WindowInsetsController instead.

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 left position.

void setTranslationY(float translationY)

Sets the vertical location of this view relative to its top position.

void setTranslationZ(float translationZ)

Sets the depth location of this view relative to its elevation.

void setVerticalFadingEdgeEnabled(boolean verticalFadingEdgeEnabled)

Define whether the vertical edges should be faded when this view is scrolled vertically.

void setVerticalScrollBarEnabled(boolean verticalScrollBarEnabled)

Define whether the vertical scrollbar should be drawn or not.

void setVerticalScrollbarPosition(int position)

Set the position of the vertical scroll bar.

void setVerticalScrollbarThumbDrawable(Drawable drawable)

Defines the vertical scrollbar thumb drawable

void setVerticalScrollbarTrackDrawable(Drawable drawable)

Defines the vertical scrollbar track drawable

void setViewTranslationCallback(ViewTranslationCallback callback)

Sets a ViewTranslationCallback that is used to display/hide the translated information.

void setVisibility(int visibility)

Set the visibility state of this view.

void setWillNotCacheDrawing(boolean willNotCacheDrawing)

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, setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

void setWillNotDraw(boolean willNotDraw)

If this view doesn't do any drawing on its own, set this flag to allow further optimizations.

void setWindowInsetsAnimationCallback(WindowInsetsAnimation.Callback callback)

Sets a WindowInsetsAnimation.Callback to be notified about animations of windows that cause insets.

void setX(float x)

Sets the visual x position of this view, in pixels.

void setY(float y)

Sets the visual y position of this view, in pixels.

void setZ(float z)

Sets the visual z position of this view, in pixels.

boolean showContextMenu()

Shows the context menu for this view.

boolean showContextMenu(float x, float y)

Shows the context menu for this view anchored to the specified view-relative coordinate.

ActionMode startActionMode(ActionMode.Callback callback, int type)

Start an action mode with the given type.

ActionMode startActionMode(ActionMode.Callback callback)

Start an action mode with the default type ActionMode#TYPE_PRIMARY.

void startAnimation(Animation animation)

Start the specified animation now.

final boolean startDrag(ClipData data, View.DragShadowBuilder shadowBuilder, Object myLocalState, int flags)

This method was deprecated in API level 24. Use startDragAndDrop() for newer platform versions.

final boolean startDragAndDrop(ClipData data, View.DragShadowBuilder shadowBuilder, Object myLocalState, int flags)

Starts a drag and drop operation.

boolean startNestedScroll(int axes)

Begin a nestable scroll operation along the given axes.

void stopNestedScroll()

Stop a nested scroll in progress.

String toString()

Returns a string representation of the object.

void transformMatrixToGlobal(Matrix matrix)

Modifies the input matrix such that it maps view-local coordinates to on-screen coordinates.

void transformMatrixToLocal(Matrix matrix)

Modifies the input matrix such that it maps on-screen coordinates to view-local coordinates.

void unscheduleDrawable(Drawable who, Runnable what)

Cancels a scheduled action on a drawable.

void unscheduleDrawable(Drawable who)

Unschedule any events associated with the given Drawable.

final void updateDragShadow(View.DragShadowBuilder shadowBuilder)

Updates the drag shadow for the ongoing drag and drop operation.

boolean verifyDrawable(Drawable who)

If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying.

boolean willNotCacheDrawing()

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, setLayerType(int, android.graphics.Paint) handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas from either a Bitmap or Picture and call draw(android.graphics.Canvas) on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as Config.HARDWARE bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy API is recommended.

boolean willNotDraw()

Returns whether or not this View draws on its own.

From class java.lang.Object

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeout, int nanos)

Causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

final void wait(long timeout)

Causes the current thread to wait until either another thread invokes the notify() method or the notifyAll() method for this object, or a specified amount of time has elapsed.

final void wait()

Causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object.

From interface android.view.ViewParent

abstract void bringChildToFront(View child)

Change the z order of the child so it's on top of all other children.

abstract boolean canResolveLayoutDirection()

Tells if this view parent can resolve the layout direction.

abstract boolean canResolveTextAlignment()

Tells if this view parent can resolve the text alignment.

abstract boolean canResolveTextDirection()

Tells if this view parent can resolve the text direction.

abstract void childDrawableStateChanged(View child)

This method is called on the parent when a child's drawable state has changed.

abstract void childHasTransientStateChanged(View child, boolean hasTransientState)

Called when a child view now has or no longer is tracking transient state.

abstract void clearChildFocus(View child)

Called when a child of this parent is giving up focus

abstract void createContextMenu(ContextMenu menu)

Have the parent populate the specified context menu if it has anything to add (and then recurse on its parent).

default OnBackInvokedDispatcher findOnBackInvokedDispatcherForChild(View child, View requester)

Walk up the View hierarchy to find the nearest OnBackInvokedDispatcher.

abstract View focusSearch(View v, int direction)

Find the nearest view in the specified direction that wants to take focus

abstract void focusableViewAvailable(View v)

Tells the parent that a new focusable view has become available.

abstract boolean getChildVisibleRect(View child, Rect r, Point offset)

Compute the visible part of a rectangular region defined in terms of a child view's coordinates.

abstract int getLayoutDirection()

Return this view parent layout direction.

abstract ViewParent getParent()

Returns the parent if it exists, or null.

abstract ViewParent getParentForAccessibility()

Gets the parent of a given View for accessibility.

abstract int getTextAlignment()

Return this view parent text alignment.

abstract int getTextDirection()

Return this view parent text direction.

abstract void invalidateChild(View child, Rect r)

This method was deprecated in API level 26. Use onDescendantInvalidated(android.view.View, android.view.View) instead.

abstract ViewParent invalidateChildInParent(int[] location, Rect r)

This method was deprecated in API level 26. Use onDescendantInvalidated(android.view.View, android.view.View) instead.

abstract boolean isLayoutDirectionResolved()

Tells if this view parent layout direction is resolved.

abstract boolean isLayoutRequested()

Indicates whether layout was requested on this view parent.

abstract boolean isTextAlignmentResolved()

Tells if this view parent text alignment is resolved.

abstract boolean isTextDirectionResolved()

Tells if this view parent text direction is resolved.

abstract View keyboardNavigationClusterSearch(View currentCluster, int direction)

Find the nearest keyboard navigation cluster in the specified direction.

abstract void notifySubtreeAccessibilityStateChanged(View child, View source, int changeType)

Notifies a view parent that the accessibility state of one of its descendants has changed and that the structure of the subtree is different.

default void onDescendantInvalidated(View child, View target)

The target View has been invalidated, or has had a drawing property changed that requires the hierarchy to re-render.

abstract boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed)

Request a fling from a nested scroll.

abstract boolean onNestedPreFling(View target, float velocityX, float velocityY)

React to a nested fling before the target view consumes it.

abstract boolean onNestedPrePerformAccessibilityAction(View target, int action, Bundle arguments)

React to an accessibility action delegated by a target descendant view before the target processes it.

abstract void onNestedPreScroll(View target, int dx, int dy, int[] consumed)

React to a nested scroll in progress before the target view consumes a portion of the scroll.

abstract void onNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed)

React to a nested scroll in progress.

abstract void onNestedScrollAccepted(View child, View target, int nestedScrollAxes)

React to the successful claiming of a nested scroll operation.

abstract boolean onStartNestedScroll(View child, View target, int nestedScrollAxes)

React to a descendant view initiating a nestable scroll operation, claiming the nested scroll operation if appropriate.

abstract void onStopNestedScroll(View target)

React to a nested scroll operation ending.

abstract void recomputeViewAttributes(View child)

Tell view hierarchy that the global view attributes need to be re-evaluated.

abstract void requestChildFocus(View child, View focused)

Called when a child of this parent wants focus

abstract boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate)

Called when a child of this group wants a particular rectangle to be positioned onto the screen.

abstract void requestDisallowInterceptTouchEvent(boolean disallowIntercept)

Called when a child does not want this parent and its ancestors to intercept touch events with ViewGroup#onInterceptTouchEvent(MotionEvent).

abstract void requestFitSystemWindows()

Ask that a new dispatch of View.fitSystemWindows(Rect) be performed.

abstract void requestLayout()

Called when something has changed which has invalidated the layout of a child of this view parent.

abstract boolean requestSendAccessibilityEvent(View child, AccessibilityEvent event)

Called by a child to request from its parent to send an AccessibilityEvent.

abstract void requestTransparentRegion(View child)

Called when a child wants the view hierarchy to gather and report transparent regions to the window compositor.

abstract boolean showContextMenuForChild(View originalView)

Shows the context menu for the specified view or its ancestors.

abstract boolean showContextMenuForChild(View originalView, float x, float y)

Shows the context menu for the specified view or its ancestors anchored to the specified view-relative coordinate.

abstract ActionMode startActionModeForChild(View originalView, ActionMode.Callback callback, int type)

Start an action mode of a specific type for the specified view.

abstract ActionMode startActionModeForChild(View originalView, ActionMode.Callback callback)

Start an action mode for the specified view with the default type ActionMode#TYPE_PRIMARY.

From interface android.view.ViewManager

abstract void addView(View view, ViewGroup.LayoutParams params)

Assign the passed LayoutParams to the passed View and add the view to the window.

abstract void removeView(View view)
abstract void updateViewLayout(View view, ViewGroup.LayoutParams params)

From interface android.graphics.drawable.Drawable.Callback

abstract void invalidateDrawable(Drawable who)

Called when the drawable needs to be redrawn.

abstract void scheduleDrawable(Drawable who, Runnable what, long when)

A Drawable can call this to schedule the next frame of its animation.

abstract void unscheduleDrawable(Drawable who, Runnable what)

A Drawable can call this to unschedule an action previously scheduled with scheduleDrawable(Drawable, Runnable, long).

From interface android.view.KeyEvent.Callback

abstract boolean onKeyDown(int keyCode, KeyEvent event)

Called when a key down event has occurred.

abstract boolean onKeyLongPress(int keyCode, KeyEvent event)

Called when a long press has occurred.

abstract boolean onKeyMultiple(int keyCode, int count, KeyEvent event)

Called when a user's interaction with an analog control, such as flinging a trackball, generates simulated down/up events for the same key multiple times in quick succession.

abstract boolean onKeyUp(int keyCode, KeyEvent event)

Called when a key up event has occurred.

From interface android.view.accessibility.AccessibilityEventSource

abstract void sendAccessibilityEvent(int eventType)

Handles the request for sending an AccessibilityEvent given the event type.

abstract void sendAccessibilityEventUnchecked(AccessibilityEvent event)

Handles the request for sending an AccessibilityEvent.

XML attributes

android:alignmentMode

When set to alignMargins, causes alignment to take place between the outer boundary of a view, as defined by its margins. When set to alignBounds, causes alignment to take place between the edges of the view. The default is alignMargins. See GridLayout.setAlignmentMode(int).

Must be one of the following constant values.

ConstantValueDescription
alignBounds 0 Align the bounds of the children. See GridLayout.ALIGN_BOUNDS.
alignMargins 1 Align the margins of the children. See GridLayout.ALIGN_MARGINS.

Related methods:

  • setAlignmentMode(int)

android:columnCount

The maximum number of columns to create when automatically positioning children.

May be an integer value, such as "100".

Related methods:

  • setColumnCount(int)

android:columnOrderPreserved

When set to true, forces column boundaries to appear in the same order as column indices. The default is true. See GridLayout.setColumnOrderPreserved(boolean).

May be a boolean value, such as "true" or "false".

Related methods:

  • setColumnOrderPreserved(boolean)

android:orientation

The orientation property is not used during layout. It is only used to allocate row and column parameters when they are not specified by its children's layout paramters. GridLayout works like LinearLayout in this case; putting all the components either in a single row or in a single column - depending on the value of this flag. In the horizontal case, a columnCount property may be additionally supplied to force new rows to be created when a row is full. The rowCount attribute may be used similarly in the vertical case. The default is horizontal.

Must be one of the following constant values.

ConstantValueDescription
horizontal 0 Defines an horizontal widget.
vertical 1 Defines a vertical widget.

Related methods:

  • setOrientation(int)

android:rowCount

The maximum number of rows to create when automatically positioning children.

May be an integer value, such as "100".

Related methods:

  • setRowCount(int)

android:rowOrderPreserved

When set to true, forces row boundaries to appear in the same order as row indices. The default is true. See GridLayout.setRowOrderPreserved(boolean).

May be a boolean value, such as "true" or "false".

Related methods:

  • setRowOrderPreserved(boolean)

android:useDefaultMargins

When set to true, tells GridLayout to use default margins when none are specified in a view's layout parameters. The default value is false. See GridLayout.setUseDefaultMargins(boolean).

May be a boolean value, such as "true" or "false".

Related methods:

  • setUseDefaultMargins(boolean)

Constants

ALIGN_BOUNDS

Added in API level 14

public static final int ALIGN_BOUNDS

This constant is an alignmentMode. When the alignmentMode is set to ALIGN_BOUNDS, alignment is made between the edges of each component's raw view boundary: i.e. the area delimited by the component's: top, left, bottom and right properties.

For example, when GridLayout is in ALIGN_BOUNDS mode, children that belong to a row group that uses TOP alignment will all return the same value when their View.getTop() method is called.

See also:

  • setAlignmentMode(int)

Constant Value: 0 (0x00000000)

ALIGN_MARGINS

Added in API level 14

public static final int ALIGN_MARGINS

This constant is an alignmentMode. When the alignmentMode is set to ALIGN_MARGINS, the bounds of each view are extended outwards, according to their margins, before the edges of the resulting rectangle are aligned.

For example, when GridLayout is in ALIGN_MARGINS mode, the quantity top - layoutParams.topMargin is the same for all children that belong to a row group that uses TOP alignment.

See also:

  • setAlignmentMode(int)

Constant Value: 1 (0x00000001)

HORIZONTAL

Added in API level 14

public static final int HORIZONTAL

The horizontal orientation.

Constant Value: 0 (0x00000000)

UNDEFINED

Added in API level 14

public static final int UNDEFINED

The constant used to indicate that a value is undefined. Fields can use this value to indicate that their values have not yet been set. Similarly, methods can return this value to indicate that there is no suitable value that the implementation can return. The value used for the constant (currently Integer#MIN_VALUE) is intended to avoid confusion between valid values whose sign may not be known.

Constant Value: -2147483648 (0x80000000)

VERTICAL

Added in API level 14

public static final int VERTICAL

The vertical orientation.

Constant Value: 1 (0x00000001)

Fields

BASELINE

Added in API level 14

public static final GridLayout.Alignment BASELINE

Indicates that a view should be aligned with the baselines of the other views in its cell group. This constant may only be used as an alignment in rowSpecs.

See also:

  • View.getBaseline()

BOTTOM

Added in API level 14

public static final GridLayout.Alignment BOTTOM

Indicates that a view should be aligned with the bottom edges of the other views in its cell group.

CENTER

Added in API level 14

public static final GridLayout.Alignment CENTER

Indicates that a view should be centered with the other views in its cell group. This constant may be used in both rowSpecs and columnSpecs.

END

Added in API level 16

public static final GridLayout.Alignment END

Indicates that a view should be aligned with the end edges of the other views in its cell group.

FILL

Added in API level 14

public static final GridLayout.Alignment FILL

Indicates that a view should expanded to fit the boundaries of its cell group. This constant may be used in both rowSpecs and columnSpecs.

LEFT

Added in API level 14

public static final GridLayout.Alignment LEFT

Indicates that a view should be aligned with the left edges of the other views in its cell group.

RIGHT

Added in API level 14

public static final GridLayout.Alignment RIGHT

Indicates that a view should be aligned with the right edges of the other views in its cell group.

START

Added in API level 16

public static final GridLayout.Alignment START

Indicates that a view should be aligned with the start edges of the other views in its cell group.

TOP

Added in API level 14

public static final GridLayout.Alignment TOP

Indicates that a view should be aligned with the top edges of the other views in its cell group.

Public constructors

GridLayout

Added in API level 14

public GridLayout (Context context)
Parameters
context Context

GridLayout

Added in API level 14

public GridLayout (Context context, 
                AttributeSet attrs)
Parameters
context Context
attrs AttributeSet

GridLayout

Added in API level 14

public GridLayout (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)
Parameters
context Context
attrs AttributeSet
defStyleAttr int

GridLayout

Added in API level 21

public GridLayout (Context context, 
                AttributeSet attrs, 
                int defStyleAttr, 
                int defStyleRes)
Parameters
context Context
attrs AttributeSet
defStyleAttr int
defStyleRes int

Public methods

generateLayoutParams

Added in API level 14

public GridLayout.LayoutParams generateLayoutParams (AttributeSet attrs)

Returns a new set of layout parameters based on the supplied attributes set.

Parameters
attrs AttributeSet: the attributes to build the layout parameters from
Returns
GridLayout.LayoutParams an instance of ViewGroup.LayoutParams or one of its descendants

getAccessibilityClassName

Added in API level 23

public CharSequence getAccessibilityClassName ()

Return the class name of this object to be used for accessibility purposes. Subclasses should only override this if they are implementing something that should be seen as a completely new class of view when used by accessibility, unrelated to the class it is deriving from. This is used to fill in AccessibilityNodeInfo.setClassName.

Returns
CharSequence

getAlignmentMode

Added in API level 14

public int getAlignmentMode ()

Returns the alignment mode.

Related XML Attributes:

  • android:alignmentMode
Returns
int the alignment mode; either ALIGN_BOUNDS or ALIGN_MARGINS Value is ALIGN_BOUNDS, or ALIGN_MARGINS

See also:

  • ALIGN_BOUNDS
  • ALIGN_MARGINS
  • setAlignmentMode(int)

getColumnCount

Added in API level 14

public int getColumnCount ()

Returns the current number of columns. This is either the last value that was set with setColumnCount(int) or, if no such value was set, the maximum value of each the upper bounds defined in LayoutParams#columnSpec.

Related XML Attributes:

  • android:columnCount
Returns
int the current number of columns

See also:

  • setColumnCount(int)
  • GridLayout.LayoutParams.columnSpec

getOrientation

Added in API level 14

public int getOrientation ()

Returns the current orientation.

Related XML Attributes:

  • android:orientation
Returns
int either HORIZONTAL or VERTICAL Value is HORIZONTAL, or VERTICAL

See also:

  • setOrientation(int)

getRowCount

Added in API level 14

public int getRowCount ()

Returns the current number of rows. This is either the last value that was set with setRowCount(int) or, if no such value was set, the maximum value of each the upper bounds defined in LayoutParams#rowSpec.

Related XML Attributes:

  • android:rowCount
Returns
int the current number of rows

See also:

  • setRowCount(int)
  • GridLayout.LayoutParams.rowSpec

getUseDefaultMargins

Added in API level 14

public boolean getUseDefaultMargins ()

Returns whether or not this GridLayout will allocate default margins when no corresponding layout parameters are defined.

Related XML Attributes:

  • android:useDefaultMargins
Returns
boolean true if default margins should be allocated

See also:

  • setUseDefaultMargins(boolean)

isColumnOrderPreserved

Added in API level 14

public boolean isColumnOrderPreserved ()

Returns whether or not column boundaries are ordered by their grid indices.

Related XML Attributes:

  • android:columnOrderPreserved
Returns
boolean true if column boundaries must appear in the order of their indices, false otherwise

See also:

  • setColumnOrderPreserved(boolean)

isRowOrderPreserved

Added in API level 14

public boolean isRowOrderPreserved ()

Returns whether or not row boundaries are ordered by their grid indices.

Related XML Attributes:

  • android:rowOrderPreserved
Returns
boolean true if row boundaries must appear in the order of their indices, false otherwise

See also:

  • setRowOrderPreserved(boolean)

onViewAdded

Added in API level 23

public void onViewAdded (View child)

Called when a new child is added to this ViewGroup. Overrides should always call super.onViewAdded.

Parameters
child View: the added child view

onViewRemoved

Added in API level 23

public void onViewRemoved (View child)

Called when a child view is removed from this ViewGroup. Overrides should always call super.onViewRemoved.

Parameters
child View: the removed child view

requestLayout

Added in API level 14

public void requestLayout ()

Call this when something has changed which has invalidated the layout of this view. This will schedule a layout pass of the view tree. This should not be called while the view hierarchy is currently in a layout pass (isInLayout(). If layout is happening, the request may be honored at the end of the current layout pass (and then layout will run again) or after the current frame is drawn and the next layout occurs.

Subclasses which override this method should call the superclass method to handle possible request-during-layout errors correctly.

If you override this method you must call through to the superclass implementation.

setAlignmentMode

Added in API level 14

public void setAlignmentMode (int alignmentMode)

Sets the alignment mode to be used for all of the alignments between the children of this container.

The default value of this property is ALIGN_MARGINS.

Related XML Attributes:

  • android:alignmentMode
Parameters
alignmentMode int: either ALIGN_BOUNDS or ALIGN_MARGINS Value is ALIGN_BOUNDS, or ALIGN_MARGINS

See also:

  • ALIGN_BOUNDS
  • ALIGN_MARGINS
  • getAlignmentMode()

setColumnCount

Added in API level 14

public void setColumnCount (int columnCount)

ColumnCount is used only to generate default column/column indices when they are not specified by a component's layout parameters.

Related XML Attributes:

  • android:columnCount
Parameters
columnCount int: the number of columns.

See also:

  • getColumnCount()
  • GridLayout.LayoutParams.columnSpec

setColumnOrderPreserved

Added in API level 14

public void setColumnOrderPreserved (boolean columnOrderPreserved)

When this property is true, GridLayout is forced to place the column boundaries so that their associated grid indices are in ascending order in the view.

When this property is false GridLayout is at liberty to place the horizontal column boundaries in whatever order best fits the given constraints.

The default value of this property is true.

Related XML Attributes:

  • android:columnOrderPreserved
Parameters
columnOrderPreserved boolean: use true to force GridLayout to respect the order of column boundaries.

See also:

  • isColumnOrderPreserved()

setOrientation

Added in API level 14

public void setOrientation (int orientation)

GridLayout uses the orientation property for two purposes:

  • To control the 'direction' in which default row/column indices are generated when they are not specified in a component's layout parameters.
  • To control which axis should be processed first during the layout operation: when orientation is HORIZONTAL the horizontal axis is laid out first.

The order in which axes are laid out is important if, for example, the height of one of GridLayout's children is dependent on its width - and its width is, in turn, dependent on the widths of other components.

If your layout contains a TextView (or derivative: Button, EditText, CheckBox, etc.) which is in multi-line mode (the default) it is normally best to leave GridLayout's orientation as HORIZONTAL - because TextView is capable of deriving its height for a given width, but not the other way around.

Other than the effects above, orientation does not affect the actual layout operation of GridLayout, so it's fine to leave GridLayout in HORIZONTAL mode even if the height of the intended layout greatly exceeds its width.

The default value of this property is HORIZONTAL.

Related XML Attributes:

  • android:orientation
Parameters
orientation int: either HORIZONTAL or VERTICAL Value is HORIZONTAL, or VERTICAL

See also:

  • getOrientation()

setRowCount

Added in API level 14

public void setRowCount (int rowCount)

RowCount is used only to generate default row/column indices when they are not specified by a component's layout parameters.

Related XML Attributes:

  • android:rowCount
Parameters
rowCount int: the number of rows

See also:

  • getRowCount()
  • GridLayout.LayoutParams.rowSpec

setRowOrderPreserved

Added in API level 14

public void setRowOrderPreserved (boolean rowOrderPreserved)

When this property is true, GridLayout is forced to place the row boundaries so that their associated grid indices are in ascending order in the view.

When this property is false GridLayout is at liberty to place the vertical row boundaries in whatever order best fits the given constraints.

The default value of this property is true.

Related XML Attributes:

  • android:rowOrderPreserved
Parameters
rowOrderPreserved boolean: true to force GridLayout to respect the order of row boundaries

See also:

  • isRowOrderPreserved()

setUseDefaultMargins

Added in API level 14

public void setUseDefaultMargins (boolean useDefaultMargins)

When true, GridLayout allocates default margins around children based on the child's visual characteristics. Each of the margins so defined may be independently overridden by an assignment to the appropriate layout parameter.

When false, the default value of all margins is zero.

When setting to true, consider setting the value of the alignmentMode property to ALIGN_BOUNDS.

The default value of this property is false.

Related XML Attributes:

  • android:useDefaultMargins
Parameters
useDefaultMargins boolean: use true to make GridLayout allocate default margins

See also:

  • getUseDefaultMargins()
  • setAlignmentMode(int)
  • ViewGroup.MarginLayoutParams.leftMargin
  • ViewGroup.MarginLayoutParams.topMargin
  • ViewGroup.MarginLayoutParams.rightMargin
  • ViewGroup.MarginLayoutParams.bottomMargin

spec

Added in API level 21

public static GridLayout.Spec spec (int start, 
                float weight)

Equivalent to: spec(start, 1, weight).

Parameters
start int: the start
weight float: the weight
Returns
GridLayout.Spec

spec

Added in API level 14

public static GridLayout.Spec spec (int start)

Return a Spec, spec, where:

  • spec.span = [start, start + 1]

To leave the start index undefined, use the value UNDEFINED.

Parameters
start int: the start index
Returns
GridLayout.Spec

See also:

  • spec(int, int)

spec

Added in API level 21

public static GridLayout.Spec spec (int start, 
                int size, 
                GridLayout.Alignment alignment, 
                float weight)

Return a Spec, spec, where:

  • spec.span = [start, start + size]
  • spec.alignment = alignment
  • spec.weight = weight

To leave the start index undefined, use the value UNDEFINED.

Parameters
start int: the start
size int: the size
alignment GridLayout.Alignment: the alignment
weight float: the weight
Returns
GridLayout.Spec

spec

Added in API level 21

public static GridLayout.Spec spec (int start, 
                GridLayout.Alignment alignment, 
                float weight)

Equivalent to: spec(start, 1, alignment, weight).

Parameters
start int: the start
alignment GridLayout.Alignment: the alignment
weight float: the weight
Returns
GridLayout.Spec

spec

Added in API level 14

public static GridLayout.Spec spec (int start, 
                int size, 
                GridLayout.Alignment alignment)

Equivalent to: spec(start, size, alignment, 0f).

Parameters
start int: the start
size int: the size
alignment GridLayout.Alignment: the alignment
Returns
GridLayout.Spec

spec

Added in API level 14

public static GridLayout.Spec spec (int start, 
                GridLayout.Alignment alignment)

Return a Spec, spec, where:

  • spec.span = [start, start + 1]
  • spec.alignment = alignment

To leave the start index undefined, use the value UNDEFINED.

Parameters
start int: the start index
alignment GridLayout.Alignment: the alignment
Returns
GridLayout.Spec

See also:

  • spec(int, int, Alignment)

spec

Added in API level 21

public static GridLayout.Spec spec (int start, 
                int size, 
                float weight)

Equivalent to: spec(start, 1, default_alignment, weight) - where default_alignment is specified in GridLayout.LayoutParams.

Parameters
start int: the start
size int: the size
weight float: the weight
Returns
GridLayout.Spec

spec

Added in API level 14

public static GridLayout.Spec spec (int start, 
                int size)

Return a Spec, spec, where:

  • spec.span = [start, start + size]

To leave the start index undefined, use the value UNDEFINED.

Parameters
start int: the start
size int: the size
Returns
GridLayout.Spec

See also:

  • spec(int, Alignment)

Protected methods

checkLayoutParams

Added in API level 14

protected boolean checkLayoutParams (ViewGroup.LayoutParams p)
Parameters
p ViewGroup.LayoutParams
Returns
boolean

generateDefaultLayoutParams

Added in API level 14

protected GridLayout.LayoutParams generateDefaultLayoutParams ()

Returns a set of default layout parameters. These parameters are requested when the View passed to addView(android.view.View) has no layout parameters already set. If null is returned, an exception is thrown from addView.

Returns
GridLayout.LayoutParams a set of default layout parameters or null

generateLayoutParams

Added in API level 14

protected GridLayout.LayoutParams generateLayoutParams (ViewGroup.LayoutParams lp)

Returns a safe set of layout parameters based on the supplied layout params. When a ViewGroup is passed a View whose layout params do not pass the test of checkLayoutParams(android.view.ViewGroup.LayoutParams), this method is invoked. This method should return a new set of layout params suitable for this ViewGroup, possibly by copying the appropriate attributes from the specified set of layout params.

Parameters
lp ViewGroup.LayoutParams: The layout parameters to convert into a suitable set of layout parameters for this ViewGroup.
Returns
GridLayout.LayoutParams an instance of ViewGroup.LayoutParams or one of its descendants

onLayout

Added in API level 14

protected void onLayout (boolean changed, 
                int left, 
                int top, 
                int right, 
                int bottom)

Called from layout when this view should assign a size and position to each of its children. Derived classes with children should override this method and call layout on each of their children.

Parameters
changed boolean: This is a new size or position for this view
left int: Left position, relative to parent
top int: Top position, relative to parent
right int: Right position, relative to parent
bottom int: Bottom position, relative to parent

onMeasure

Added in API level 14

protected void onMeasure (int widthSpec, 
                int heightSpec)

Measure the view and its content to determine the measured width and the measured height. This method is invoked by measure(int, int) and should be overridden by subclasses to provide accurate and efficient measurement of their contents.

CONTRACT: When overriding this method, you must call setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by measure(int, int). Calling the superclass' onMeasure(int, int) is a valid use.

The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override onMeasure(int, int) to provide better measurements of their content.

If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (getSuggestedMinimumHeight() and getSuggestedMinimumWidth()).

Parameters
widthSpec int: horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
heightSpec int: vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2022-06-08 UTC.

[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }] [{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]

When Deserializing an object using the readObject method you must cast the return value to the desired class type?

When deserializing an object using the readObject method, you must cast the return value to the desired class type. When the code in a try block may throw more than one type of exception, you need to write a catch clause for each type of exception that could potentially be thrown.
When catching multiple exceptions that are related to one another through inheritance, you should handle the more specialized exception classes before the more general exception classes. To serialize an object and write it to the file, use this method of the ObjectOutputStream class.

What happens if a program does not handle an unchecked exception quizlet?

If your code does not handle and exception when it is thrown, this prints an error message and crashes the program.

When an exception is thrown by a method that is executing under several layers of method calls?

8) When an exception is thrown by a method that is executing under several layers of method calls, a stack trace indicates the method executing when an exception occurred and all of the methods that were called in order to execute that method.