Added in API level 1

ViewGroup


abstract class ViewGroup : View, ViewManager, ViewParent
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup

A ViewGroup is a special view that can contain other views (called children.) The view group is the base class for layouts and views containers. This class also defines the android.view.ViewGroup.LayoutParams class which serves as the base class for layouts parameters.

Also see LayoutParams for layout attributes.

Here is a complete implementation of a custom ViewGroup that implements a simple android.widget.FrameLayout along with the ability to stack children in left and right gutters.

If you are implementing XML layout attributes as shown in the example, this is the corresponding definition for them that would go in res/values/attrs.xml:

Finally the layout manager can be used in an XML layout like so:

Summary

Nested classes
open

LayoutParams are used by views to tell their parents how they want to be laid out.

open

Per-child layout information for layouts that support margins.

abstract

Interface definition for a callback to be invoked when the hierarchy within this view changed.

XML attributes
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.
Inherited XML attributes
Constants
static Int

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

static Int

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

static Int

This view will get focus before any of its descendants.

static Int

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

static Int

This constant is a layoutMode.

static Int

This constant is a layoutMode.

static Int

Used to indicate that all drawing caches should be kept in memory.

static Int

Used to indicate that the animation drawing cache should be kept in memory.

static Int

Used to indicate that no drawing cache should be kept in memory.

static Int

Used to indicate that the scrolling drawing cache should be kept in memory.

Inherited constants
Public constructors
ViewGroup(context: Context!)

ViewGroup(context: Context!, attrs: AttributeSet!)

ViewGroup(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

ViewGroup(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

Public methods
open Unit

open Unit

Adds extra data to an AccessibilityNodeInfo based on an explicit request for the additional data.

open Unit
addFocusables(views: ArrayList<View!>!, direction: Int, focusableMode: Int)

open Unit

open Boolean

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

open Unit

open Unit
addView(child: View!)

Adds a child view.

open Unit
addView(child: View!, params: ViewGroup.LayoutParams!)

Adds a child view with the specified layout parameters.

open Unit
addView(child: View!, index: Int)

Adds a child view.

open Unit
addView(child: View!, index: Int, params: ViewGroup.LayoutParams!)

Adds a child view with the specified layout parameters.

open Unit
addView(child: View!, width: Int, height: Int)

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

open Unit

open Unit

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

open Unit
childHasTransientStateChanged(child: View, childHasTransientState: Boolean)

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

open Unit

open Unit

Removes any pending animations for views that have been removed.

open Unit

open WindowInsets!

open Boolean

open Unit

open Unit

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

open Unit

open Boolean

open Unit

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

open Boolean

open Boolean

open Boolean

open Unit

open Unit

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

open Unit

Dispatch creation of ViewStructure down the hierarchy.

open Unit
dispatchScrollCaptureSearch(localVisibleRect: Rect, windowOffset: Point, targets: Consumer<ScrollCaptureTarget!>)

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

open Unit

open Unit

open Unit

open Boolean

open Boolean

open Boolean
dispatchUnhandledMove(focused: View!, direction: Int)

open Unit

open Unit

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

open Unit

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

open WindowInsets

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

open WindowInsetsAnimation.Bounds

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

open Unit

open Unit

open Unit

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

open View!

open OnBackInvokedDispatcher?

Walk up the View hierarchy to find the nearest OnBackInvokedDispatcher.

open Unit
findViewsWithText(outViews: ArrayList<View!>!, text: CharSequence!, flags: Int)

open View!
focusSearch(focused: View!, direction: Int)

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

open Unit

open Boolean

open ViewGroup.LayoutParams!

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

open CharSequence!

open View!
getChildAt(index: Int)

Returns the view at the specified position in the group.

open Int

Returns the number of children in the group.

Int
getChildDrawingOrder(drawingPosition: Int)

Converts drawing order position to container position.

open static Int
getChildMeasureSpec(spec: Int, padding: Int, childDimension: Int)

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

open Boolean
getChildVisibleRect(child: View!, r: Rect!, offset: Point!)

open Boolean

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

open Boolean

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.

open Int

Gets the descendant focusability of this view group.

open View!

Returns the focused child of this view, if any.

open LayoutAnimationController!

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

open Animation.AnimationListener!

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

open Int

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

open LayoutTransition!

Gets the LayoutTransition object for this ViewGroup.

open Int

Return the current axes of nested scrolling for this ViewGroup.

open ViewGroupOverlay!

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

open Int

Returns an integer indicating what types of drawing caches are kept in memory.

open Boolean

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

open Boolean

Returns true if this view has or contains focus

open Boolean

open Int
indexOfChild(child: View!)

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

Unit
invalidateChild(child: View!, dirty: Rect!)

Don't call or override this method.

open ViewParent!
invalidateChildInParent(location: IntArray!, dirty: Rect!)

Don't call or override this method.

open Boolean

Indicates whether this ViewGroup will always try to draw its children using their drawing cache.

open Boolean

Indicates whether the children's drawing cache is used during a layout animation.

open Boolean

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

open Boolean

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

open Boolean

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

open Unit

Unit
layout(l: Int, t: Int, r: Int, b: Int)

open Unit
notifySubtreeAccessibilityStateChanged(child: View, source: View, changeType: Int)

Unit
offsetDescendantRectToMyCoords(descendant: View!, rect: Rect!)

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

Unit
offsetRectIntoDescendantCoords(descendant: View!, rect: Rect!)

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

open Unit
onDescendantInvalidated(child: View, target: View)

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

open Boolean

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

open Boolean

Implement this method to intercept all touch screen motion events.

open Boolean
onNestedFling(target: View, velocityX: Float, velocityY: Float, consumed: Boolean)

open Boolean
onNestedPreFling(target: View, velocityX: Float, velocityY: Float)

open Boolean

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

open Unit
onNestedPreScroll(target: View, dx: Int, dy: Int, consumed: IntArray)

open Unit
onNestedScroll(target: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int)

open Unit
onNestedScrollAccepted(child: View, target: View, axes: Int)

open Boolean

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

open PointerIcon!
onResolvePointerIcon(event: MotionEvent!, pointerIndex: Int)

open Boolean
onStartNestedScroll(child: View, target: View, nestedScrollAxes: Int)

open Unit

open Unit
onViewAdded(child: View!)

Called when a new child is added to this ViewGroup.

open Unit

Called when a child view is removed from this ViewGroup.

open Unit
propagateRequestedFrameRate(frameRate: Float, forceOverride: Boolean)

You can set the preferred frame rate for a ViewGroup and its children using a positive number or by specifying the preferred frame rate category using constants, including REQUESTED_FRAME_RATE_CATEGORY_NO_PREFERENCE, REQUESTED_FRAME_RATE_CATEGORY_LOW, REQUESTED_FRAME_RATE_CATEGORY_NORMAL, REQUESTED_FRAME_RATE_CATEGORY_HIGH.

open Unit

open Unit

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

open Unit

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.

open Unit
removeView(view: View!)

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

open Unit
removeViewAt(index: Int)

Removes the view at the specified position in the group.

open Unit

Removes a view during layout.

open Unit
removeViews(start: Int, count: Int)

Removes the specified range of views from the group.

open Unit
removeViewsInLayout(start: Int, count: Int)

Removes a range of views during layout.

open Unit
requestChildFocus(child: View!, focused: View!)

open Boolean
requestChildRectangleOnScreen(child: View, rectangle: Rect!, immediate: Boolean)

open Unit

open Boolean
requestFocus(direction: Int, previouslyFocusedRect: Rect!)

Call this to try to give focus to a specific view or to one of its descendants and give it hints about the direction and a specific rectangle that the focus is coming from.

open Boolean

open Unit

open Boolean

open Unit

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

open Unit

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

open Unit

Indicates whether this ViewGroup will always try to draw its children using their drawing cache.

open Unit

Enables or disables the children's drawing cache during a layout animation.

open Unit
setClipChildren(clipChildren: Boolean)

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

open Unit
setClipToPadding(clipToPadding: Boolean)

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.

open Unit

Set the descendant focusability of this view group.

open Unit

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

open Unit

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

open Unit
setLayoutMode(layoutMode: Int)

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

open Unit

Sets the LayoutTransition object for this ViewGroup.

open Unit

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

open Unit

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

open Unit
setPersistentDrawingCache(drawingCacheToKeep: Int)

Indicates what types of drawing caches should be kept in memory after they have been created.

open Unit

You can set the preferred frame rate for a ViewGroup using a positive number or by specifying the preferred frame rate category using constants, including REQUESTED_FRAME_RATE_CATEGORY_NO_PREFERENCE, REQUESTED_FRAME_RATE_CATEGORY_LOW, REQUESTED_FRAME_RATE_CATEGORY_NORMAL, REQUESTED_FRAME_RATE_CATEGORY_HIGH.

open Unit
setTouchscreenBlocksFocus(touchscreenBlocksFocus: Boolean)

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

open Unit
setTransitionGroup(isTransitionGroup: Boolean)

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

open Unit

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

open Boolean

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

open Boolean
showContextMenuForChild(originalView: View!)

open Boolean
showContextMenuForChild(originalView: View!, x: Float, y: Float)

open ActionMode!
startActionModeForChild(originalView: View!, callback: ActionMode.Callback!)

open ActionMode!
startActionModeForChild(originalView: View!, callback: ActionMode.Callback!, type: Int)

open Unit

Runs the layout animation.

open Unit

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.

open Unit

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

open Unit

Protected methods
open Boolean
addViewInLayout(child: View!, index: Int, params: ViewGroup.LayoutParams!)

Adds a view during layout.

open Boolean
addViewInLayout(child: View!, index: Int, params: ViewGroup.LayoutParams!, preventRequestLayout: Boolean)

Adds a view during layout.

open Unit
attachLayoutAnimationParameters(child: View!, params: ViewGroup.LayoutParams!, index: Int, count: Int)

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

open Unit
attachViewToParent(child: View!, index: Int, params: ViewGroup.LayoutParams!)

Attaches a view to this view group.

open Boolean

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

open Boolean

open Unit

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

open Unit
debug(depth: Int)

open Unit

Detaches all views from the parent.

open Unit

Detaches a view from its parent.

open Unit

Detaches a view from its parent.

open Unit
detachViewsFromParent(start: Int, count: Int)

Detaches a range of views from their parents.

open Unit

Called by draw to draw the child views.

open Unit

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

open Boolean

open Boolean

open Boolean

open Unit

open Unit

open Unit

open Unit

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

open Unit
dispatchVisibilityChanged(changedView: View, visibility: Int)

open Boolean
drawChild(canvas: Canvas, child: View!, drawingTime: Long)

Draw one child of this View Group.

open Unit

open ViewGroup.LayoutParams!

Returns a set of default layout parameters.

open ViewGroup.LayoutParams!

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

open Int
getChildDrawingOrder(childCount: Int, drawingPosition: Int)

Converts drawing order position to container position.

open Boolean

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

open Boolean

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

open Boolean

Indicates whether the ViewGroup is currently drawing its children using their drawing cache.

open Unit
measureChild(child: View!, parentWidthMeasureSpec: Int, parentHeightMeasureSpec: Int)

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

open Unit
measureChildWithMargins(child: View!, parentWidthMeasureSpec: Int, widthUsed: Int, parentHeightMeasureSpec: Int, heightUsed: Int)

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.

open Unit
measureChildren(widthMeasureSpec: Int, heightMeasureSpec: Int)

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

open Unit

open IntArray!

open Unit

abstract Unit
onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int)

open Boolean
onRequestFocusInDescendants(direction: Int, previouslyFocusedRect: Rect!)

Look for a descendant to call android.

open Unit
removeDetachedView(child: View!, animate: Boolean)

Finishes the removal of a detached view.

open Unit

Enables or disables the drawing cache for each child of this view group.

open Unit

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

open Unit

Tells the ViewGroup to draw its children using their drawing cache.

open Unit

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.

Inherited functions
Inherited properties

XML attributes

android:addStatesFromChildren

android:addStatesFromChildren
Sets whether this ViewGroup's drawable states also include its children's drawable states. This is used, for example, to make a group appear to be focused when its child EditText or button is focused.

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

android:alwaysDrawnWithCache

android:alwaysDrawnWithCache
Defines whether the ViewGroup should always draw its children using their drawing cache or not. The default value is true. Deprecated: The view drawing cache was largely made obsolete with the introduction of hardware-accelerated rendering in API 11.

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

android:animateLayoutChanges

android:animateLayoutChanges
Defines whether changes in layout (caused by adding and removing items) should cause a LayoutTransition to run. When this flag is set to true, a default LayoutTransition object will be set on the ViewGroup container and default animations will run when these layout changes occur.

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

android:animationCache

android:animationCache
Defines whether layout animations should create a drawing cache for their children. Enabling the animation cache consumes more memory and requires a longer initialization but provides better performance. The animation cache is enabled by default.

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

android:clipChildren

android:clipChildren
Defines whether a child is limited to draw inside of its bounds or not. This is useful with animations that scale the size of the children to more than 100% for instance. In such a case, this property should be set to false to allow the children to draw outside of their bounds. The default value of this property is true.

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

android:clipToPadding

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. This property is set to true by default.

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

android:descendantFocusability

android:descendantFocusability
Defines the relationship between the ViewGroup and its descendants when looking for a View to take focus.

Must be one of the following constant values.

Constant Value Description
afterDescendants 1 The ViewGroup will get focus only if none of its descendants want it.
beforeDescendants 0 The ViewGroup will get focus before any of its descendants.
blocksDescendants 2 The ViewGroup will block its descendants from receiving focus.

android:layoutAnimation

android:layoutAnimation
Defines the layout animation to use the first time the ViewGroup is laid out. Layout animations can also be started manually after the first layout.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

android:layoutMode

android:layoutMode
Defines the layout mode of this ViewGroup.

Must be one of the following constant values.

Constant Value Description
clipBounds 0 Use the children's clip bounds when laying out this container.
opticalBounds 1 Use the children's optical bounds when laying out this container.

android:persistentDrawingCache

android:persistentDrawingCache
Defines the persistence of the drawing cache. The drawing cache might be enabled by a ViewGroup for all its children in specific situations (for instance during a scrolling.) This property lets you persist the cache in memory after its initial usage. Persisting the cache consumes more memory but may prevent frequent garbage collection if the cache is created over and over again. By default the persistence is set to scrolling. Deprecated: The view drawing cache was largely made obsolete with the introduction of hardware-accelerated rendering in API 11.

Must be one or more (separated by '|') of the following constant values.

Constant Value Description
all 3 The drawing cache is always persisted.
animation 1 The drawing cache is persisted after a layout animation.
none 0 The drawing cache is not persisted after use.
scrolling 2 The drawing cache is persisted after a scroll.

android:splitMotionEvents

android:splitMotionEvents
Sets whether this ViewGroup should split MotionEvents to separate child views during touch event dispatch. If false (default prior to HONEYCOMB), touch events will be dispatched to the child view where the first pointer went down until the last pointer goes up. If true (default for HONEYCOMB and later), touch events may be dispatched to multiple children. MotionEvents for each pointer will be dispatched to the child view where the initial ACTION_DOWN event happened. See android.view.ViewGroup#setMotionEventSplittingEnabled(boolean) for more information.

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

Constants

CLIP_TO_PADDING_MASK

Added in API level 1
protected static val CLIP_TO_PADDING_MASK: Int

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

Value: 34

FOCUS_AFTER_DESCENDANTS

Added in API level 1
static val FOCUS_AFTER_DESCENDANTS: Int

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

Value: 262144

FOCUS_BEFORE_DESCENDANTS

Added in API level 1
static val FOCUS_BEFORE_DESCENDANTS: Int

This view will get focus before any of its descendants.

Value: 131072

FOCUS_BLOCK_DESCENDANTS

Added in API level 1
static val FOCUS_BLOCK_DESCENDANTS: Int

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

Value: 393216

LAYOUT_MODE_CLIP_BOUNDS

Added in API level 18
static val LAYOUT_MODE_CLIP_BOUNDS: Int

This constant is a layoutMode. Clip bounds are the raw values of left, top, right and bottom.

Value: 0

LAYOUT_MODE_OPTICAL_BOUNDS

Added in API level 18
static val LAYOUT_MODE_OPTICAL_BOUNDS: Int

This constant is a layoutMode. Optical bounds describe where a widget appears to be. They sit inside the clip bounds which need to cover a larger area to allow other effects, such as shadows and glows, to be drawn.

Value: 1

PERSISTENT_ALL_CACHES

Added in API level 1
Deprecated in API level 28
static val PERSISTENT_ALL_CACHES: Int

Deprecated: 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 android.graphics.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.

Used to indicate that all drawing caches should be kept in memory.

Value: 3

PERSISTENT_ANIMATION_CACHE

Added in API level 1
Deprecated in API level 28
static val PERSISTENT_ANIMATION_CACHE: Int

Deprecated: 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 android.graphics.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.

Used to indicate that the animation drawing cache should be kept in memory.

Value: 1

PERSISTENT_NO_CACHE

Added in API level 1
Deprecated in API level 28
static val PERSISTENT_NO_CACHE: Int

Deprecated: 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 android.graphics.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.

Used to indicate that no drawing cache should be kept in memory.

Value: 0

PERSISTENT_SCROLLING_CACHE

Added in API level 1
Deprecated in API level 28
static val PERSISTENT_SCROLLING_CACHE: Int

Deprecated: 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 android.graphics.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.

Used to indicate that the scrolling drawing cache should be kept in memory.

Value: 2

Public constructors

ViewGroup

Added in API level 1
ViewGroup(context: Context!)

ViewGroup

Added in API level 1
ViewGroup(
    context: Context!,
    attrs: AttributeSet!)

ViewGroup

Added in API level 1
ViewGroup(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int)

ViewGroup

Added in API level 21
ViewGroup(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int,
    defStyleRes: Int)

Public methods

addChildrenForAccessibility

Added in API level 16
open fun addChildrenForAccessibility(outChildren: ArrayList<View!>!): Unit
Parameters
outChildren ArrayList<View!>!: The output list that will receive children for accessibility.

addExtraDataToAccessibilityNodeInfo

Added in API level 26
open fun addExtraDataToAccessibilityNodeInfo(
    info: AccessibilityNodeInfo,
    extraDataKey: String,
    arguments: Bundle?
): Unit

Adds extra data to an AccessibilityNodeInfo based on an explicit request for the additional data.

This method only needs overloading if the node is marked as having extra data available.

Parameters
info AccessibilityNodeInfo: The info to which to add the extra data. Never null.
extraDataKey String: A key specifying the type of extra data to add to the info. The extra data should be added to the Bundle returned by the info's AccessibilityNodeInfo.getExtras method. Never null.
arguments Bundle?: A Bundle holding any arguments relevant for this request. May be null if the service provided no arguments.

addFocusables

Added in API level 4
open fun addFocusables(
    views: ArrayList<View!>!,
    direction: Int,
    focusableMode: Int
): Unit
Parameters
views ArrayList<View!>!: Focusable views found so far or null if all we are interested is the number of focusables.
direction Int: The direction of the focus. Value is android.view.View#FOCUS_BACKWARD, android.view.View#FOCUS_FORWARD, android.view.View#FOCUS_LEFT, android.view.View#FOCUS_UP, android.view.View#FOCUS_RIGHT, or android.view.View#FOCUS_DOWN
focusableMode Int: The type of focusables to be added. Value is either 0 or a combination of android.view.View#FOCUSABLES_ALL, and android.view.View#FOCUSABLES_TOUCH_MODE

addKeyboardNavigationClusters

Added in API level 26
open fun addKeyboardNavigationClusters(
    views: MutableCollection<View!>,
    direction: Int
): Unit
Parameters
views MutableCollection<View!>: Keyboard navigation cluster roots found so far This value cannot be null.
direction Int: Direction to look

addStatesFromChildren

Added in API level 1
open fun addStatesFromChildren(): Boolean

Returns whether this ViewGroup's drawable states also include its children's drawable states. This is used, for example, to make a group appear to be focused when its child EditText or button is focused.

addTouchables

Added in API level 1
open fun addTouchables(views: ArrayList<View!>!): Unit
Parameters
views ArrayList<View!>!: Touchable views found so far

addView

Added in API level 1
open fun addView(child: View!): Unit

Adds a child view. If no layout parameters are already set on the child, the default parameters for this ViewGroup are set on the child.

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

Parameters
child View!: the child view to add

addView

Added in API level 1
open fun addView(
    child: View!,
    params: ViewGroup.LayoutParams!
): Unit

Adds a child view with the specified layout parameters.

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

Parameters
view The view to be added to this window.
params ViewGroup.LayoutParams!: the layout parameters to set on the child
child View!: the child view to add

addView

Added in API level 1
open fun addView(
    child: View!,
    index: Int
): Unit

Adds a child view. If no layout parameters are already set on the child, the default parameters for this ViewGroup are set on the child.

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

Parameters
child View!: the child view to add
index Int: the position at which to add the child

addView

Added in API level 1
open fun addView(
    child: View!,
    index: Int,
    params: ViewGroup.LayoutParams!
): Unit

Adds a child view with the specified layout parameters.

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

Parameters
child View!: the child view to add
index Int: the position at which to add the child or -1 to add last
params ViewGroup.LayoutParams!: the layout parameters to set on the child

addView

Added in API level 1
open fun addView(
    child: View!,
    width: Int,
    height: Int
): Unit

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

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

Parameters
child View!: the child view to add

bringChildToFront

Added in API level 1
open fun bringChildToFront(child: View!): Unit
Parameters
child View!: The child to bring to the top of the z order

childDrawableStateChanged

Added in API level 1
open fun childDrawableStateChanged(child: View): Unit

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

Parameters
child View: The child whose drawable state has changed. This value cannot be null.

childHasTransientStateChanged

Added in API level 19
open fun childHasTransientStateChanged(
    child: View,
    childHasTransientState: Boolean
): Unit

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

Parameters
child View: Child view whose state has changed This value cannot be null.
hasTransientState true if this child has transient state

clearChildFocus

Added in API level 1
open fun clearChildFocus(child: View!): Unit
Parameters
child View!: The view that is giving up focus

clearDisappearingChildren

Added in API level 1
open fun clearDisappearingChildren(): Unit

Removes any pending animations for views that have been removed. Call this if you don't want animations for exiting views to stack up.

clearFocus

Added in API level 1
open fun clearFocus(): Unit

dispatchApplyWindowInsets

Added in API level 20
open fun dispatchApplyWindowInsets(insets: WindowInsets!): WindowInsets!
Parameters
insets WindowInsets!: Insets to apply
Return
WindowInsets! The provided insets minus the insets that were consumed

dispatchCapturedPointerEvent

Added in API level 26
open fun dispatchCapturedPointerEvent(event: MotionEvent!): Boolean
Parameters
event MotionEvent!: The motion event to be dispatched.
Return
Boolean True if the event was handled by the view, false otherwise.

dispatchConfigurationChanged

Added in API level 8
open fun dispatchConfigurationChanged(newConfig: Configuration!): Unit
Parameters
newConfig Configuration!: The new resource configuration.

dispatchCreateViewTranslationRequest

Added in API level 31
open fun dispatchCreateViewTranslationRequest(
    viewIds: MutableMap<AutofillId!, LongArray!>,
    supportedFormats: IntArray,
    capability: TranslationCapability!,
    requests: MutableList<ViewTranslationRequest!>
): Unit

Dispatch to collect the ViewTranslationRequests for translation purpose by traversing the hierarchy when the app requests ui translation. Typically, this method should only be overridden by subclasses that provide a view hierarchy (such as ViewGroup). Other classes should override View.onCreateViewTranslationRequest for normal view or override View.onVirtualViewTranslationResponses for view contains virtual children. When requested to start the ui translation, the system will call this method to traverse the view hierarchy to collect ViewTranslationRequests and create a android.view.translation.Translator to translate the requests. All the ViewTranslationRequests must be added when the traversal is done.

The default implementation calls View.onCreateViewTranslationRequest for normal view or calls View.onVirtualViewTranslationResponses for view contains virtual children to build ViewTranslationRequest if the view should be translated. The view is marked as having transient state so that recycling of views doesn't prevent the system from attaching the response to it. Therefore, if overriding this method, you should set or reset the transient state.

The implementation calls dispatchCreateViewTranslationRequest for all the child views.
Parameters
viewIds MutableMap<AutofillId!, LongArray!>: This value cannot be null.
supportedFormats IntArray: This value cannot be null. Value is android.view.translation.TranslationSpec#DATA_FORMAT_TEXT
capability TranslationCapability!: This value may be null.
requests MutableList<ViewTranslationRequest!>: This value cannot be null.

dispatchDisplayHint

Added in API level 8
open fun dispatchDisplayHint(hint: Int): Unit
Parameters
hint Int: A hint about whether or not this view is displayed: VISIBLE or INVISIBLE. Value is android.view.View#VISIBLE, android.view.View#INVISIBLE, or android.view.View#GONE

dispatchDragEvent

Added in API level 11
open fun dispatchDragEvent(event: DragEvent!): Boolean

dispatchDrawableHotspotChanged

Added in API level 22
open fun dispatchDrawableHotspotChanged(
    x: Float,
    y: Float
): Unit

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

Parameters
x Float: hotspot x coordinate
y Float: hotspot y coordinate

dispatchKeyEvent

Added in API level 1
open fun dispatchKeyEvent(event: KeyEvent!): Boolean
Parameters
event KeyEvent!: The key event to be dispatched.
Return
Boolean True if the event was handled, false otherwise.

dispatchKeyEventPreIme

Added in API level 3
open fun dispatchKeyEventPreIme(event: KeyEvent!): Boolean
Parameters
event KeyEvent!: The key event to be dispatched.
Return
Boolean True if the event was handled, false otherwise.

dispatchKeyShortcutEvent

Added in API level 1
open fun dispatchKeyShortcutEvent(event: KeyEvent!): Boolean
Parameters
event KeyEvent!: The key event to be dispatched.
Return
Boolean True if the event was handled by the view, false otherwise.

dispatchPointerCaptureChanged

Added in API level 26
open fun dispatchPointerCaptureChanged(hasCapture: Boolean): Unit

dispatchProvideAutofillStructure

Added in API level 26
open fun dispatchProvideAutofillStructure(
    structure: ViewStructure,
    flags: Int
): Unit

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

The default implementation does the following:

Typically, this method should only be overridden by subclasses that provide a view hierarchy (such as ViewGroup) - other classes should override onProvideAutofillStructure(android.view.ViewStructure,int) or onProvideAutofillVirtualStructure(android.view.ViewStructure,int) instead.

When overridden, it must:

  • Either call super.dispatchProvideAutofillStructure(structure, flags) or explicitly set the AutofillId in the structure (for example, by calling structure.setAutofillId(getAutofillId())).
  • Decide how to handle the AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS flag - when set, all views in the structure should be considered important for autofill, regardless of what isImportantForAutofill() returns. We encourage you to respect this flag to provide a better user experience - this flag is typically used when an user explicitly requested autofill. If the flag is not set, then only views marked as important for autofill should be included in the structure - skipping non-important views optimizes the overall autofill performance.

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

Parameters
structure ViewStructure: fill in with structured view data for autofill purposes. This value cannot be null.
flags Int: Value is either 0 or android.view.View#AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS

dispatchProvideStructure

Added in API level 23
open fun dispatchProvideStructure(structure: ViewStructure!): Unit

Dispatch creation of ViewStructure down the hierarchy. This implementation adds in all child views of the view group, in addition to calling the default View implementation.

dispatchScrollCaptureSearch

Added in API level 31
open fun dispatchScrollCaptureSearch(
    localVisibleRect: Rect,
    windowOffset: Point,
    targets: Consumer<ScrollCaptureTarget!>
): Unit

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

Parameters
localVisibleRect Rect: the visible area of this ViewGroup in local coordinates, according to the parent This value cannot be null.
windowOffset Point: the offset of this view within the window This value cannot be null.
targets Consumer<ScrollCaptureTarget!>: accepts potential scroll capture targets; results.accept may be called zero or more times on the calling thread before onScrollCaptureSearch returns This value cannot be null.

dispatchSetActivated

Added in API level 11
open fun dispatchSetActivated(activated: Boolean): Unit
Parameters
activated Boolean: The new activated state

dispatchSetSelected

Added in API level 1
open fun dispatchSetSelected(selected: Boolean): Unit
Parameters
selected Boolean: The new selected state

dispatchSystemUiVisibilityChanged

Added in API level 11
open fun dispatchSystemUiVisibilityChanged(visible: Int): Unit

Deprecated: Deprecated in Java.

dispatchTouchEvent

Added in API level 1
open fun dispatchTouchEvent(ev: MotionEvent!): Boolean
Parameters
event The motion event to be dispatched.
Return
Boolean True if the event was handled by the view, false otherwise.

dispatchTrackballEvent

Added in API level 1
open fun dispatchTrackballEvent(event: MotionEvent!): Boolean
Parameters
event MotionEvent!: The motion event to be dispatched.
Return
Boolean True if the event was handled by the view, false otherwise.

dispatchUnhandledMove

Added in API level 1
open fun dispatchUnhandledMove(
    focused: View!,
    direction: Int
): Boolean
Parameters
focused View!: The currently focused view.
direction Int: The direction focus wants to move. One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT. Value is android.view.View#FOCUS_LEFT, android.view.View#FOCUS_UP, android.view.View#FOCUS_RIGHT, or android.view.View#FOCUS_DOWN
Return
Boolean True if the this view consumed this unhandled move.

dispatchWindowFocusChanged

Added in API level 1
open fun dispatchWindowFocusChanged(hasFocus: Boolean): Unit
Parameters
hasFocus Boolean: True if the window containing this view now has focus, false otherwise.

dispatchWindowInsetsAnimationEnd

Added in API level 30
open fun dispatchWindowInsetsAnimationEnd(animation: WindowInsetsAnimation): Unit

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

Parameters
animation WindowInsetsAnimation: This value cannot be null.

dispatchWindowInsetsAnimationPrepare

Added in API level 30
open fun dispatchWindowInsetsAnimationPrepare(animation: WindowInsetsAnimation): Unit

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

Parameters
animation WindowInsetsAnimation: This value cannot be null.

dispatchWindowInsetsAnimationProgress

Added in API level 30
open fun dispatchWindowInsetsAnimationProgress(
    insets: WindowInsets,
    runningAnimations: MutableList<WindowInsetsAnimation!>
): WindowInsets

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

Parameters
insets WindowInsets: This value cannot be null.
runningAnimations MutableList<WindowInsetsAnimation!>: This value cannot be null.
Return
WindowInsets This value cannot be null.

dispatchWindowInsetsAnimationStart

Added in API level 30
open fun dispatchWindowInsetsAnimationStart(
    animation: WindowInsetsAnimation,
    bounds: WindowInsetsAnimation.Bounds
): WindowInsetsAnimation.Bounds

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

Parameters
animation WindowInsetsAnimation: This value cannot be null.
bounds WindowInsetsAnimation.Bounds: This value cannot be null.
Return
WindowInsetsAnimation.Bounds This value cannot be null.

dispatchWindowSystemUiVisiblityChanged

Added in API level 16
open fun dispatchWindowSystemUiVisiblityChanged(visible: Int): Unit

Deprecated: Deprecated in Java.

dispatchWindowVisibilityChanged

Added in API level 1
open fun dispatchWindowVisibilityChanged(visibility: Int): Unit
Parameters
visibility Int: The new visibility of the window. Value is android.view.View#VISIBLE, android.view.View#INVISIBLE, or android.view.View#GONE

endViewTransition

Added in API level 11
open fun endViewTransition(view: View!): Unit

This method should always be called following an earlier call to startViewTransition(android.view.View). The given View is finally removed from its parent and will no longer be displayed. Note that this method does not perform the functionality of removing a view from its parent; it just discontinues the display of a View that has previously been removed.

Return
Unit view The View object that has been removed but is being kept around in the visible hierarchy by an earlier call to startViewTransition(android.view.View).

findFocus

Added in API level 1
open fun findFocus(): View!
Return
View! The view that currently has focus, or null if no focused view can be found.

findOnBackInvokedDispatcherForChild

Added in API level 33
open fun findOnBackInvokedDispatcherForChild(
    child: View,
    requester: View
): OnBackInvokedDispatcher?

Walk up the View hierarchy to find the nearest OnBackInvokedDispatcher.

Parameters
child View: The direct child of this view for which to find a dispatcher. This value cannot be null.
requester View: The requester that will use the dispatcher. Can be the same as child. This value cannot be null.
Return
OnBackInvokedDispatcher? The OnBackInvokedDispatcher from this or the nearest ancestor, or null if the view is both not attached and have no ancestor providing an OnBackInvokedDispatcher.

findViewsWithText

Added in API level 14
open fun findViewsWithText(
    outViews: ArrayList<View!>!,
    text: CharSequence!,
    flags: Int
): Unit
Parameters
outViews ArrayList<View!>!: The output list of matching Views.
searched The text to match against.
flags Int: Value is either 0 or a combination of android.view.View#FIND_VIEWS_WITH_TEXT, and android.view.View#FIND_VIEWS_WITH_CONTENT_DESCRIPTION

focusSearch

Added in API level 1
open fun focusSearch(
    focused: View!,
    direction: Int
): View!

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

Parameters
v The view that currently has focus
direction Int: One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT, or 0 for not applicable.
focused View!: The view that currently has focus

focusableViewAvailable

Added in API level 1
open fun focusableViewAvailable(v: View!): Unit
Parameters
v View!: The view that has become newly focusable

gatherTransparentRegion

Added in API level 1
open fun gatherTransparentRegion(region: Region?): Boolean
Parameters
region Region?: The transparent region for this ViewAncestor (window). This value may be null.
Return
Boolean Returns true if the effective visibility of the view at this point is opaque, regardless of the transparent region; returns false if it is possible for underlying windows to be seen behind the view.

generateLayoutParams

Added in API level 1
open fun generateLayoutParams(attrs: AttributeSet!): ViewGroup.LayoutParams!

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

Parameters
attrs AttributeSet!: the attributes to build the layout parameters from
Return
ViewGroup.LayoutParams! an instance of android.view.ViewGroup.LayoutParams or one of its descendants

getAccessibilityClassName

Added in API level 23
open fun getAccessibilityClassName(): CharSequence!

getChildAt

Added in API level 1
open fun getChildAt(index: Int): View!

Returns the view at the specified position in the group.

Parameters
index Int: the position at which to get the view from
Return
View! the view at the specified position or null if the position does not exist within the group

getChildCount

Added in API level 1
open fun getChildCount(): Int

Returns the number of children in the group.

Return
Int a positive integer representing the number of children in the group

getChildDrawingOrder

Added in API level 29
fun getChildDrawingOrder(drawingPosition: Int): Int

Converts drawing order position to container position.

Children are not necessarily drawn in the order in which they appear in the container. ViewGroups can enable a custom ordering via setChildrenDrawingOrderEnabled(boolean). This method returns the container position of a child that appears in the given position in the current drawing order.

Parameters
drawingPosition Int: the drawing order position.
Return
Int the container position of a child for this drawing order position.

getChildMeasureSpec

Added in API level 1
open static fun getChildMeasureSpec(
    spec: Int,
    padding: Int,
    childDimension: Int
): Int

Does the hard part of measureChildren: figuring out the MeasureSpec to pass to a particular child. This method figures out the right MeasureSpec for one dimension (height or width) of one child view. The goal is to combine information from our MeasureSpec with the LayoutParams of the child to get the best possible results. For example, if the this view knows its size (because its MeasureSpec has a mode of EXACTLY), and the child has indicated in its LayoutParams that it wants to be the same size as the parent, the parent should ask the child to layout given an exact size.

Parameters
spec Int: The requirements for this view
padding Int: The padding of this view for the current dimension and margins, if applicable
childDimension Int: How big the child wants to be in the current dimension
Return
Int a MeasureSpec integer for the child

getChildVisibleRect

Added in API level 1
open fun getChildVisibleRect(
    child: View!,
    r: Rect!,
    offset: Point!
): Boolean
Parameters
child View!: A child View, whose rectangular visible region we want to compute
r Rect!: The input rectangle, defined in the child coordinate system. Will be overwritten to contain the resulting visible rectangle, expressed in global (root) coordinates
offset Point!: The input coordinates of a point, defined in the child coordinate system. As with the r parameter, this will be overwritten to contain the global (root) coordinates of that point. A null value is valid (in case you are not interested in this result)
Return
Boolean true if the resulting rectangle is not empty, false otherwise

getClipChildren

Added in API level 18
open fun getClipChildren(): Boolean

Returns whether this group's children are clipped to their bounds before drawing. The default value is true.

Return
Boolean True if the group's children will be clipped to their bounds, false otherwise.

getClipToPadding

Added in API level 21
open fun getClipToPadding(): Boolean

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.

By default, children are clipped to the padding of their parent Viewgroup. This clipping behavior is only enabled if padding is non-zero.

Return
Boolean true if this ViewGroup clips children to its padding and resizes (but doesn't clip) any EdgeEffect to the padded region, false otherwise.

getDescendantFocusability

Added in API level 1
open fun getDescendantFocusability(): Int

Gets the descendant focusability of this view group. The descendant focusability defines the relationship between this view group and its descendants when looking for a view to take focus in requestFocus(int,android.graphics.Rect).

Return
Int one of FOCUS_BEFORE_DESCENDANTS, FOCUS_AFTER_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS.

getFocusedChild

Added in API level 1
open fun getFocusedChild(): View!

Returns the focused child of this view, if any. The child may have focus or contain focus.

Return
View! the focused child or null.

getLayoutAnimation

Added in API level 1
open fun getLayoutAnimation(): LayoutAnimationController!

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

Return
LayoutAnimationController! the current animation controller

getLayoutAnimationListener

Added in API level 1
open fun getLayoutAnimationListener(): Animation.AnimationListener!

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

Return
Animation.AnimationListener! an android.view.animation.Animation.AnimationListener

getLayoutMode

Added in API level 18
open fun getLayoutMode(): Int

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

If no layoutMode was explicitly set, either programmatically or in an XML resource, the method returns the layoutMode of the view's parent ViewGroup if such a parent exists, otherwise the method returns a default value of LAYOUT_MODE_CLIP_BOUNDS.

Return
Int the layout mode to use during layout operations

getLayoutTransition

Added in API level 11
open fun getLayoutTransition(): LayoutTransition!

Gets the LayoutTransition object for this ViewGroup. If the LayoutTransition object is not null, changes in layout which occur because of children being added to or removed from the ViewGroup will be animated according to the animations defined in that LayoutTransition object. By default, the transition object is null (so layout changes are not animated).

Return
LayoutTransition! LayoutTranstion The LayoutTransition object that will animated changes in layout. A value of null means no transition will run on layout changes.

getNestedScrollAxes

Added in API level 21
open fun getNestedScrollAxes(): Int

Return the current axes of nested scrolling for this ViewGroup.

A ViewGroup returning something other than SCROLL_AXIS_NONE is currently acting as a nested scrolling parent for one or more descendant views in the hierarchy.

Return
Int Flags indicating the current axes of nested scrolling

getOverlay

Added in API level 18
open fun getOverlay(): ViewGroupOverlay!

Returns the ViewGroupOverlay for this view group, creating it if it does not yet exist. In addition to ViewOverlay's support for drawables, ViewGroupOverlay allows views to be added to the overlay. These views, like overlay drawables, are visual-only; they do not receive input events and should not be used as anything other than a temporary representation of a view in a parent container, such as might be used by an animation effect.

Note: Overlays do not currently work correctly with SurfaceView or TextureView; contents in overlays for these types of views may not display correctly.

Return
ViewGroupOverlay! The ViewGroupOverlay object for this view.

getPersistentDrawingCache

Added in API level 1
Deprecated in API level 28
open fun getPersistentDrawingCache(): Int

Deprecated: 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 android.graphics.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.

Returns an integer indicating what types of drawing caches are kept in memory.

Return
Int one or a combination of PERSISTENT_NO_CACHE, PERSISTENT_ANIMATION_CACHE, PERSISTENT_SCROLLING_CACHE and PERSISTENT_ALL_CACHES

getTouchscreenBlocksFocus

Added in API level 21
open fun getTouchscreenBlocksFocus(): Boolean

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

hasFocus

Added in API level 1
open fun hasFocus(): Boolean

Returns true if this view has or contains focus

Return
Boolean true if this view has or contains focus

hasTransientState

Added in API level 16
open fun hasTransientState(): Boolean
Return
Boolean true if the view has transient state

indexOfChild

Added in API level 1
open fun indexOfChild(child: View!): Int

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

Parameters
child View!: the view for which to get the position
Return
Int a positive integer representing the position of the view in the group, or -1 if the view does not exist in the group

invalidateChild

Added in API level 1
fun invalidateChild(
    child: View!,
    dirty: Rect!
): Unit

Deprecated: Use onDescendantInvalidated(android.view.View,android.view.View) instead to observe updates to draw state in descendants.

Don't call or override this method. It is used for the implementation of the view hierarchy.

Parameters
child View!: The child which is dirty
r The area within the child that is invalid

invalidateChildInParent

Added in API level 1
open fun invalidateChildInParent(
    location: IntArray!,
    dirty: Rect!
): ViewParent!

Deprecated: Use onDescendantInvalidated(android.view.View,android.view.View) instead to observe updates to draw state in descendants.

Don't call or override this method. It is used for the implementation of the view hierarchy. This implementation returns null if this ViewGroup does not have a parent, if this ViewGroup is already fully invalidated or if the dirty rectangle does not intersect with this ViewGroup's bounds.

Parameters
location IntArray!: An array of 2 ints containing the left and top coordinates of the child to invalidate
r The area within the child that is invalid
Return
ViewParent! the parent of this ViewParent or null

isAlwaysDrawnWithCacheEnabled

Added in API level 1
Deprecated in API level 23
open fun isAlwaysDrawnWithCacheEnabled(): Boolean

Deprecated: As of android.os.Build.VERSION_CODES#M, this property is ignored. Child views may no longer have their caching behavior disabled by parents.

Indicates whether this ViewGroup will always try to draw its children using their drawing cache. By default this property is enabled.

Return
Boolean true if the animation cache is enabled, false otherwise

isAnimationCacheEnabled

Added in API level 1
Deprecated in API level 23
open fun isAnimationCacheEnabled(): Boolean

Deprecated: As of android.os.Build.VERSION_CODES#M, this property is ignored. Caching behavior of children may be controlled through View.setLayerType(int, Paint).

Indicates whether the children's drawing cache is used during a layout animation. By default, the drawing cache is enabled but this will prevent nested layout animations from working. To nest animations, you must disable the cache.

Return
Boolean true if the animation cache is enabled, false otherwise

isLayoutSuppressed

Added in API level 29
open fun isLayoutSuppressed(): Boolean

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

Return
Boolean true if layout calls are currently suppressed, false otherwise.

isMotionEventSplittingEnabled

Added in API level 11
open fun isMotionEventSplittingEnabled(): Boolean

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

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

isTransitionGroup

Added in API level 21
open fun isTransitionGroup(): Boolean

Returns true if this ViewGroup should be considered as a single entity for removal when executing an Activity transition. If this is false, child elements will move individually during the transition.

Return
Boolean True if the ViewGroup should be acted on together during an Activity transition. The default value is true when there is a non-null background or if getTransitionName() is not null or if a non-null android.view.ViewOutlineProvider other than android.view.ViewOutlineProvider#BACKGROUND was given to setOutlineProvider(android.view.ViewOutlineProvider) and false otherwise.

jumpDrawablesToCurrentState

Added in API level 11
open fun jumpDrawablesToCurrentState(): Unit

layout

Added in API level 1
fun layout(
    l: Int,
    t: Int,
    r: Int,
    b: Int
): Unit
Parameters
l Int: Left position, relative to parent
t Int: Top position, relative to parent
r Int: Right position, relative to parent
b Int: Bottom position, relative to parent

notifySubtreeAccessibilityStateChanged

Added in API level 19
open fun notifySubtreeAccessibilityStateChanged(
    child: View,
    source: View,
    changeType: Int
): Unit
Parameters
child View: The direct child whose subtree has changed. This value cannot be null.
source View: The descendant view that changed. May not be null.
changeType Int: A bit mask of the types of changes that occurred. One or more of:

offsetDescendantRectToMyCoords

Added in API level 1
fun offsetDescendantRectToMyCoords(
    descendant: View!,
    rect: Rect!
): Unit

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

Parameters
descendant View!: A descendant of this view
rect Rect!: A rectangle defined in descendant's coordinate space.

offsetRectIntoDescendantCoords

Added in API level 1
fun offsetRectIntoDescendantCoords(
    descendant: View!,
    rect: Rect!
): Unit

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

Parameters
descendant View!: A descendant of this view
rect Rect!: A rectangle defined in descendant's coordinate space.

onDescendantInvalidated

Added in API level 26
open fun onDescendantInvalidated(
    child: View,
    target: View
): Unit

The target View has been invalidated, or has had a drawing property changed that requires the hierarchy to re-render. This method is called by the View hierarchy to signal ancestors that a View either needs to re-record its drawing commands, or drawing properties have changed. This is how Views schedule a drawing traversal. This signal is generally only dispatched for attached Views, since only they need to draw. If you override this method you must call through to the superclass implementation.

Parameters
child View: This value cannot be null.
target View: This value cannot be null.

onInterceptHoverEvent

Added in API level 14
open fun onInterceptHoverEvent(event: MotionEvent!): Boolean

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

This method is called before dispatching a hover event to a child of the view group or to the view group's own onHoverEvent to allow the view group a chance to intercept the hover event. This method can also be used to watch all pointer motions that occur within the bounds of the view group even when the pointer is hovering over a child of the view group rather than over the view group itself.

The view group can prevent its children from receiving hover events by implementing this method and returning true to indicate that it would like to intercept hover events. The view group must continuously return true from onInterceptHoverEvent for as long as it wishes to continue intercepting hover events from its children.

Interception preserves the invariant that at most one view can be hovered at a time by transferring hover focus from the currently hovered child to the view group or vice-versa as needed.

If this method returns true and a child is already hovered, then the child view will first receive a hover exit event and then the view group itself will receive a hover enter event in onHoverEvent. Likewise, if this method had previously returned true to intercept hover events and instead returns false while the pointer is hovering within the bounds of one of a child, then the view group will first receive a hover exit event in onHoverEvent and then the hovered child will receive a hover enter event.

The default implementation handles mouse hover on the scroll bars.

Parameters
event MotionEvent!: The motion event that describes the hover.
Return
Boolean True if the view group would like to intercept the hover event and prevent its children from receiving it.

onInterceptTouchEvent

Added in API level 1
open fun onInterceptTouchEvent(ev: MotionEvent!): Boolean

Implement this method to intercept all touch screen motion events. This allows you to watch events as they are dispatched to your children, and take ownership of the current gesture at any point.

Using this function takes some care, as it has a fairly complicated interaction with View.onTouchEvent(MotionEvent), and using it requires implementing that method as well as this one in the correct way. Events will be received in the following order:

  1. You will receive the down event here.
  2. The down event will be handled either by a child of this view group, or given to your own onTouchEvent() method to handle; this means you should implement onTouchEvent() to return true, so you will continue to see the rest of the gesture (instead of looking for a parent view to handle it). Also, by returning true from onTouchEvent(), you will not receive any following events in onInterceptTouchEvent() and all touch processing must happen in onTouchEvent() like normal.
  3. For as long as you return false from this function, each following event (up to and including the final up) will be delivered first here and then to the target's onTouchEvent().
  4. If you return true from here, you will not receive any following events: the target view will receive the same event but with the action MotionEvent.ACTION_CANCEL, and all further events will be delivered to your onTouchEvent() method and no longer appear here.
Parameters
ev MotionEvent!: The motion event being dispatched down the hierarchy.
Return
Boolean Return true to steal motion events from the children and have them dispatched to this ViewGroup through onTouchEvent(). The current target will receive an ACTION_CANCEL event, and no further messages will be delivered here.

onNestedFling

Added in API level 21
open fun onNestedFling(
    target: View,
    velocityX: Float,
    velocityY: Float,
    consumed: Boolean
): Boolean
Parameters
target View: View that initiated the nested scroll This value cannot be null.
velocityX Float: Horizontal velocity in pixels per second
velocityY Float: Vertical velocity in pixels per second
consumed Boolean: true if the child consumed the fling, false otherwise
Return
Boolean true if this parent consumed or otherwise reacted to the fling

onNestedPreFling

Added in API level 21
open fun onNestedPreFling(
    target: View,
    velocityX: Float,
    velocityY: Float
): Boolean
Parameters
target View: View that initiated the nested scroll This value cannot be null.
velocityX Float: Horizontal velocity in pixels per second
velocityY Float: Vertical velocity in pixels per second
Return
Boolean true if this parent consumed the fling ahead of the target view

onNestedPrePerformAccessibilityAction

Added in API level 22
open fun onNestedPrePerformAccessibilityAction(
    target: View,
    action: Int,
    args: Bundle?
): Boolean

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

This method may be called by a target descendant view if the target wishes to give a view in its parent chain a chance to react to the event before normal processing occurs. Most commonly this will be a scroll event such as android.view.accessibility.AccessibilityNodeInfo#ACTION_SCROLL_FORWARD. A ViewParent that supports acting as a nested scrolling parent should override this method and act accordingly to implement scrolling via accesibility systems.

Subclasses should always call super.onNestedPrePerformAccessibilityAction

Parameters
target View: The target view dispatching this action
action Int: Action being performed; see android.view.accessibility.AccessibilityNodeInfo
arguments Optional action arguments This value may be null.
args Bundle?: Optional action arguments
Return
Boolean false by default. Subclasses should return true if they handle the event.

onNestedPreScroll

Added in API level 21
open fun onNestedPreScroll(
    target: View,
    dx: Int,
    dy: Int,
    consumed: IntArray
): Unit
Parameters
target View: View that initiated the nested scroll This value cannot be null.
dx Int: Horizontal scroll distance in pixels
dy Int: Vertical scroll distance in pixels
consumed IntArray: Output. The horizontal and vertical scroll distance consumed by this parent This value cannot be null.

onNestedScroll

Added in API level 21
open fun onNestedScroll(
    target: View,
    dxConsumed: Int,
    dyConsumed: Int,
    dxUnconsumed: Int,
    dyUnconsumed: Int
): Unit
Parameters
target View: The descendent view controlling the nested scroll This value cannot be null.
dxConsumed Int: Horizontal scroll distance in pixels already consumed by target
dyConsumed Int: Vertical scroll distance in pixels already consumed by target
dxUnconsumed Int: Horizontal scroll distance in pixels not consumed by target
dyUnconsumed Int: Vertical scroll distance in pixels not consumed by target

onNestedScrollAccepted

Added in API level 21
open fun onNestedScrollAccepted(
    child: View,
    target: View,
    axes: Int
): Unit
Parameters
child View: Direct child of this ViewParent containing target This value cannot be null.
target View: View that initiated the nested scroll This value cannot be null.
nestedScrollAxes Flags consisting of View.SCROLL_AXIS_HORIZONTAL, View.SCROLL_AXIS_VERTICAL or both

onRequestSendAccessibilityEvent

Added in API level 14
open fun onRequestSendAccessibilityEvent(
    child: View!,
    event: AccessibilityEvent!
): Boolean

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

If an android.view.View.AccessibilityDelegate has been specified via calling android.view.View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate) its android.view.View.AccessibilityDelegate#onRequestSendAccessibilityEvent(ViewGroup, View, AccessibilityEvent) is responsible for handling this call.

Parameters
child View!: The child which requests sending the event.
event AccessibilityEvent!: The event to be sent.
Return
Boolean True if the event should be sent.

onResolvePointerIcon

Added in API level 24
open fun onResolvePointerIcon(
    event: MotionEvent!,
    pointerIndex: Int
): PointerIcon!
Parameters
event MotionEvent!: The MotionEvent that requires a pointer icon to be resolved for one of pointers.
pointerIndex Int: The index of the pointer in event for which to retrieve the PointerIcon. This will be between 0 and MotionEvent.getPointerCount().
Return
PointerIcon! the pointer icon to use for specified pointer, or null if a pointer icon is not specified and the default icon should be used.

onStartNestedScroll

Added in API level 21
open fun onStartNestedScroll(
    child: View,
    target: View,
    nestedScrollAxes: Int
): Boolean
Parameters
child View: Direct child of this ViewParent containing target This value cannot be null.
target View: View that initiated the nested scroll This value cannot be null.
nestedScrollAxes Int: Flags consisting of View.SCROLL_AXIS_HORIZONTAL, View.SCROLL_AXIS_VERTICAL or both
Return
Boolean true if this ViewParent accepts the nested scroll operation

onStopNestedScroll

Added in API level 21
open fun onStopNestedScroll(child: View): Unit
Parameters
target View that initiated the nested scroll This value cannot be null.

onViewAdded

Added in API level 23
open fun onViewAdded(child: View!): Unit

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
open fun onViewRemoved(child: View!): Unit

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

Parameters
child View!: the removed child view

propagateRequestedFrameRate

open fun propagateRequestedFrameRate(
    frameRate: Float,
    forceOverride: Boolean
): Unit

You can set the preferred frame rate for a ViewGroup and its children using a positive number or by specifying the preferred frame rate category using constants, including REQUESTED_FRAME_RATE_CATEGORY_NO_PREFERENCE, REQUESTED_FRAME_RATE_CATEGORY_LOW, REQUESTED_FRAME_RATE_CATEGORY_NORMAL, REQUESTED_FRAME_RATE_CATEGORY_HIGH. Keep in mind that the preferred frame rate affects the frame rate for the next frame, so use this method carefully. It's important to note that the preference is valid as long as the ViewGroup or any of its children is invalidated. To undo the frame rate propagation, call the API with REQUESTED_FRAME_RATE_CATEGORY_DEFAULT.

Parameters
frameRate Float: the preferred frame rate of the ViewGroup.
forceOverride Boolean: indicate whether it should override the frame rate of all the children with the given frame rate.

recomputeViewAttributes

Added in API level 1
open fun recomputeViewAttributes(child: View!): Unit
Parameters
child View!: View whose attributes have changed.

removeAllViews

Added in API level 1
open fun removeAllViews(): Unit

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

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

removeAllViewsInLayout

Added in API level 1
open fun removeAllViewsInLayout(): Unit

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. An example is a Gallery or a ListView, which may "have" 50 children, but actually only render the number of children that can currently fit inside the object on screen. Do not call this method unless you are extending ViewGroup and understand the view measuring and layout pipeline.

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

removeView

Added in API level 1
open fun removeView(view: View!): Unit

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

removeViewAt

Added in API level 1
open fun removeViewAt(index: Int): Unit

Removes the view at the specified position in the group.

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

Parameters
index Int: the position in the group of the view to remove

removeViewInLayout

Added in API level 1
open fun removeViewInLayout(view: View!): Unit

Removes a view during layout. This is useful if in your onLayout() method, you need to remove more views.

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

Parameters
view View!: the view to remove from the group

removeViews

Added in API level 1
open fun removeViews(
    start: Int,
    count: Int
): Unit

Removes the specified range of views from the group.

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

Parameters
start Int: the first position in the group of the range of views to remove
count Int: the number of views to remove

removeViewsInLayout

Added in API level 1
open fun removeViewsInLayout(
    start: Int,
    count: Int
): Unit

Removes a range of views during layout. This is useful if in your onLayout() method, you need to remove more views.

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

Parameters
start Int: the index of the first view to remove from the group
count Int: the number of views to remove from the group

requestChildFocus

Added in API level 1
open fun requestChildFocus(
    child: View!,
    focused: View!
): Unit
Parameters
child View!: The child of this ViewParent that wants focus. This view will contain the focused view. It is not necessarily the view that actually has focus.
focused View!: The view that is a descendant of child that actually has focus

requestChildRectangleOnScreen

Added in API level 1
open fun requestChildRectangleOnScreen(
    child: View,
    rectangle: Rect!,
    immediate: Boolean
): Boolean
Parameters
child View: The direct child making the request. This value cannot be null.
rectangle Rect!: The rectangle in the child's coordinates the child wishes to be on the screen.
immediate Boolean: True to forbid animated or delayed scrolling, false otherwise
Return
Boolean Whether the group scrolled to handle the operation

requestDisallowInterceptTouchEvent

Added in API level 1
open fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean): Unit
Parameters
disallowIntercept Boolean: True if the child does not want the parent to intercept touch events.

requestFocus

Added in API level 1
open fun requestFocus(
    direction: Int,
    previouslyFocusedRect: Rect!
): Boolean

Call this to try to give focus to a specific view or to one of its descendants and give it hints about the direction and a specific rectangle that the focus is coming from. The rectangle can help give larger views a finer grained hint about where focus is coming from, and therefore, where to show selection, or forward focus change internally. A view will not actually take focus if it is not focusable (isFocusable returns false), or if it is focusable and it is not focusable in touch mode (isFocusableInTouchMode) while the device is in touch mode. A View will not take focus if it is not visible. A View will not take focus if one of its parents has android.view.ViewGroup#getDescendantFocusability() equal to ViewGroup.FOCUS_BLOCK_DESCENDANTS. See also focusSearch(int), which is what you call to say that you have focus, and you want your parent to look for the next one. You may wish to override this method if your custom View has an internal View that it wishes to forward the request to. Looks for a view to give focus to respecting the setting specified by getDescendantFocusability(). Uses onRequestFocusInDescendants(int,android.graphics.Rect) to find focus within the children of this group when appropriate.

Parameters
direction Int: One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT
previouslyFocusedRect Rect!: The rectangle (in this View's coordinate system) to give a finer grained hint about where focus is coming from. May be null if there is no hint.
Return
Boolean Whether this view or one of its descendants actually took focus.

requestSendAccessibilityEvent

Added in API level 14
open fun requestSendAccessibilityEvent(
    child: View,
    event: AccessibilityEvent!
): Boolean
Parameters
child View: The child which requests sending the event. This value cannot be null.
event AccessibilityEvent!: The event to be sent.
Return
Boolean True if the event was sent.

requestTransparentRegion

Added in API level 1
open fun requestTransparentRegion(child: View!): Unit
Parameters
child View!: the view requesting the transparent region computation

restoreDefaultFocus

Added in API level 26
open fun restoreDefaultFocus(): Boolean
Return
Boolean Whether this view or one of its descendants actually took focus

scheduleLayoutAnimation

Added in API level 1
open fun scheduleLayoutAnimation(): Unit

Schedules the layout animation to be played after the next layout pass of this view group. This can be used to restart the layout animation when the content of the view group changes or when the activity is paused and resumed.

setAddStatesFromChildren

Added in API level 1
open fun setAddStatesFromChildren(addsStates: Boolean): Unit

Sets whether this ViewGroup's drawable states also include its children's drawable states. This is used, for example, to make a group appear to be focused when its child EditText or button is focused.

setAlwaysDrawnWithCacheEnabled

Added in API level 1
Deprecated in API level 23
open fun setAlwaysDrawnWithCacheEnabled(always: Boolean): Unit

Deprecated: As of android.os.Build.VERSION_CODES#M, this property is ignored. Child views may no longer have their caching behavior disabled by parents.

Indicates whether this ViewGroup will always try to draw its children using their drawing cache. This property can be set to true when the cache rendering is slightly different from the children's normal rendering. Renderings can be different, for instance, when the cache's quality is set to low. When this property is disabled, the ViewGroup will use the drawing cache of its children only when asked to. It's usually the task of subclasses to tell ViewGroup when to start using the drawing cache and when to stop using it.

Parameters
always Boolean: true to always draw with the drawing cache, false otherwise

setAnimationCacheEnabled

Added in API level 1
Deprecated in API level 23
open fun setAnimationCacheEnabled(enabled: Boolean): Unit

Deprecated: As of android.os.Build.VERSION_CODES#M, this property is ignored. Caching behavior of children may be controlled through View.setLayerType(int, Paint).

Enables or disables the children's drawing cache during a layout animation. By default, the drawing cache is enabled but this will prevent nested layout animations from working. To nest animations, you must disable the cache.

Parameters
enabled Boolean: true to enable the animation cache, false otherwise

setClipChildren

Added in API level 1
open fun setClipChildren(clipChildren: Boolean): Unit

By default, children are clipped to their bounds before drawing. This allows view groups to override this behavior for animations, etc.

Parameters
clipChildren Boolean: true to clip children to their bounds, false otherwise

setClipToPadding

Added in API level 1
open fun setClipToPadding(clipToPadding: Boolean): Unit

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.

By default, children are clipped to the padding of their parent ViewGroup. This clipping behavior is only enabled if padding is non-zero.

Parameters
clipToPadding Boolean: true to clip children to the padding of the group, and resize (but not clip) any EdgeEffect to the padded region. False otherwise.

setDescendantFocusability

Added in API level 1
open fun setDescendantFocusability(focusability: Int): Unit

Set the descendant focusability of this view group. This defines the relationship between this view group and its descendants when looking for a view to take focus in requestFocus(int,android.graphics.Rect).

Parameters
focusability Int: one of FOCUS_BEFORE_DESCENDANTS, FOCUS_AFTER_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS.

setLayoutAnimation

Added in API level 1
open fun setLayoutAnimation(controller: LayoutAnimationController!): Unit

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

Parameters
controller LayoutAnimationController!: the animation controller

setLayoutAnimationListener

Added in API level 1
open fun setLayoutAnimationListener(animationListener: Animation.AnimationListener!): Unit

Specifies the animation listener to which layout animation events must be sent. Only android.view.animation.Animation.AnimationListener#onAnimationStart(Animation) and android.view.animation.Animation.AnimationListener#onAnimationEnd(Animation) are invoked.

Parameters
animationListener Animation.AnimationListener!: the layout animation listener

setLayoutMode

Added in API level 18
open fun setLayoutMode(layoutMode: Int): Unit

Sets the basis of alignment during the layout of this ViewGroup. Valid values are either LAYOUT_MODE_CLIP_BOUNDS or LAYOUT_MODE_OPTICAL_BOUNDS.

Parameters
layoutMode Int: the layout mode to use during layout operations

See Also

setLayoutTransition

Added in API level 11
open fun setLayoutTransition(transition: LayoutTransition!): Unit

Sets the LayoutTransition object for this ViewGroup. If the LayoutTransition object is not null, changes in layout which occur because of children being added to or removed from the ViewGroup will be animated according to the animations defined in that LayoutTransition object. By default, the transition object is null (so layout changes are not animated).

Replacing a non-null transition will cause that previous transition to be canceled, if it is currently running, to restore this container to its correct post-transition state.

Parameters
transition LayoutTransition!: The LayoutTransition object that will animated changes in layout. A value of null means no transition will run on layout changes.

setMotionEventSplittingEnabled

Added in API level 11
open fun setMotionEventSplittingEnabled(split: Boolean): Unit

Enable or disable the splitting of MotionEvents to multiple children during touch event dispatch. This behavior is enabled by default for applications that target an SDK version of Build.VERSION_CODES.HONEYCOMB or newer.

When this option is enabled MotionEvents may be split and dispatched to different child views depending on where each pointer initially went down. This allows for user interactions such as scrolling two panes of content independently, chording of buttons, and performing independent gestures on different pieces of content.

Parameters
split Boolean: true to allow MotionEvents to be split and dispatched to multiple child views. false to only allow one child view to be the target of any MotionEvent received by this ViewGroup.

setOnHierarchyChangeListener

Added in API level 1
open fun setOnHierarchyChangeListener(listener: ViewGroup.OnHierarchyChangeListener!): Unit

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

Parameters
listener ViewGroup.OnHierarchyChangeListener!: the callback to invoke on hierarchy change

setPersistentDrawingCache

Added in API level 1
Deprecated in API level 28
open fun setPersistentDrawingCache(drawingCacheToKeep: Int): Unit

Deprecated: 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 android.graphics.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.

Indicates what types of drawing caches should be kept in memory after they have been created.

Parameters
drawingCacheToKeep Int: one or a combination of PERSISTENT_NO_CACHE, PERSISTENT_ANIMATION_CACHE, PERSISTENT_SCROLLING_CACHE and PERSISTENT_ALL_CACHES

setRequestedFrameRate

Added in API level 35
open fun setRequestedFrameRate(frameRate: Float): Unit

You can set the preferred frame rate for a ViewGroup using a positive number or by specifying the preferred frame rate category using constants, including REQUESTED_FRAME_RATE_CATEGORY_NO_PREFERENCE, REQUESTED_FRAME_RATE_CATEGORY_LOW, REQUESTED_FRAME_RATE_CATEGORY_NORMAL, REQUESTED_FRAME_RATE_CATEGORY_HIGH. Keep in mind that the preferred frame rate affects the frame rate for the next frame, so use this method carefully. It's important to note that the preference is valid as long as the ViewGroup is invalidated. Please also be aware that the requested frame rate will not propagate to child views.

Parameters
frameRate Float: the preferred frame rate of the ViewGroup.

setTouchscreenBlocksFocus

Added in API level 21
open fun setTouchscreenBlocksFocus(touchscreenBlocksFocus: Boolean): Unit

Set whether this ViewGroup should ignore focus requests for itself and its children. If this option is enabled and the ViewGroup or a descendant currently has focus, focus will proceed forward.

Parameters
touchscreenBlocksFocus Boolean: true to enable blocking focus in the presence of a touchscreen

setTransitionGroup

Added in API level 21
open fun setTransitionGroup(isTransitionGroup: Boolean): Unit

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

Parameters
isTransitionGroup Boolean: Whether or not the ViewGroup should be treated as a unit in Activity transitions. If false, the ViewGroup won't transition, only its children. If true, the entire ViewGroup will transition together.

setWindowInsetsAnimationCallback

Added in API level 30
open fun setWindowInsetsAnimationCallback(callback: WindowInsetsAnimation.Callback?): Unit

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

The callback's dispatch mode will affect whether animation callbacks are dispatched to the children of this view.

Parameters
callback WindowInsetsAnimation.Callback?: This value may be null.

shouldDelayChildPressedState

Added in API level 14
open fun shouldDelayChildPressedState(): Boolean

Return true if the pressed state should be delayed for children or descendants of this ViewGroup. Generally, this should be done for containers that can scroll, such as a List. This prevents the pressed state from appearing when the user is actually trying to scroll the content. The default implementation returns true for compatibility reasons. Subclasses that do not scroll should generally override this method and return false.

showContextMenuForChild

Added in API level 1
open fun showContextMenuForChild(originalView: View!): Boolean
Parameters
originalView View!: the source view where the context menu was first invoked
Return
Boolean true if the context menu was shown, false otherwise

showContextMenuForChild

Added in API level 24
open fun showContextMenuForChild(
    originalView: View!,
    x: Float,
    y: Float
): Boolean
Parameters
originalView View!: the source view where the context menu was first invoked
x Float: the X coordinate in pixels relative to the original view to which the menu should be anchored, or Float.NaN to disable anchoring
y Float: the Y coordinate in pixels relative to the original view to which the menu should be anchored, or Float.NaN to disable anchoring
Return
Boolean true if the context menu was shown, false otherwise

startActionModeForChild

Added in API level 11
open fun startActionModeForChild(
    originalView: View!,
    callback: ActionMode.Callback!
): ActionMode!
Parameters
originalView View!: The source view where the action mode was first invoked
callback ActionMode.Callback!: The callback that will handle lifecycle events for the action mode
Return
ActionMode! The new action mode if it was started, null otherwise

startActionModeForChild

Added in API level 23
open fun startActionModeForChild(
    originalView: View!,
    callback: ActionMode.Callback!,
    type: Int
): ActionMode!
Parameters
originalView View!: The source view where the action mode was first invoked
callback ActionMode.Callback!: The callback that will handle lifecycle events for the action mode
type Int: One of ActionMode.TYPE_PRIMARY or ActionMode.TYPE_FLOATING.
Return
ActionMode! The new action mode if it was started, null otherwise

startLayoutAnimation

Added in API level 1
open fun startLayoutAnimation(): Unit

Runs the layout animation. Calling this method triggers a relayout of this view group.

startViewTransition

Added in API level 11
open fun startViewTransition(view: View!): Unit

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. This allows animations, such as those used by android.app.Fragment and android.animation.LayoutTransition to animate the removal of views. A call to this method should always be accompanied by a later call to endViewTransition(android.view.View), such as after an animation on the View has finished, so that the View finally gets removed.

Parameters
view View!: The View object to be kept visible even if it gets removed from its parent.

suppressLayout

Added in API level 29
open fun suppressLayout(suppress: Boolean): Unit

Tells this ViewGroup to suppress all layout() calls until layout suppression is disabled with a later call to suppressLayout(false). When layout suppression is disabled, a requestLayout() call is sent if layout() was attempted while layout was being suppressed.

updateViewLayout

Added in API level 1
open fun updateViewLayout(
    view: View!,
    params: ViewGroup.LayoutParams!
): Unit

Protected methods

addViewInLayout

Added in API level 1
protected open fun addViewInLayout(
    child: View!,
    index: Int,
    params: ViewGroup.LayoutParams!
): Boolean

Adds a view during layout. This is useful if in your onLayout() method, you need to add more views (as does the list view for example). If index is negative, it means put it at the end of the list.

Parameters
child View!: the view to add to the group
index Int: the index at which the child must be added or -1 to add last
params ViewGroup.LayoutParams!: the layout parameters to associate with the child
Return
Boolean true if the child was added, false otherwise

addViewInLayout

Added in API level 1
protected open fun addViewInLayout(
    child: View!,
    index: Int,
    params: ViewGroup.LayoutParams!,
    preventRequestLayout: Boolean
): Boolean

Adds a view during layout. This is useful if in your onLayout() method, you need to add more views (as does the list view for example). If index is negative, it means put it at the end of the list.

Parameters
child View!: the view to add to the group
index Int: the index at which the child must be added or -1 to add last
params ViewGroup.LayoutParams!: the layout parameters to associate with the child
preventRequestLayout Boolean: if true, calling this method will not trigger a layout request on child
Return
Boolean true if the child was added, false otherwise

attachLayoutAnimationParameters

Added in API level 1
protected open fun attachLayoutAnimationParameters(
    child: View!,
    params: ViewGroup.LayoutParams!,
    index: Int,
    count: Int
): Unit

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

Parameters
child View!: the child to associate with animation parameters
params ViewGroup.LayoutParams!: the child's layout parameters which hold the animation parameters
index Int: the index of the child in the view group
count Int: the number of children in the view group

attachViewToParent

Added in API level 1
protected open fun attachViewToParent(
    child: View!,
    index: Int,
    params: ViewGroup.LayoutParams!
): Unit

Attaches a view to this view group. Attaching a view assigns this group as the parent, sets the layout parameters and puts the view in the list of children so that it can be retrieved by calling getChildAt(int).

This method is intended to be lightweight and makes no assumptions about whether the parent or child should be redrawn. Proper use of this method will include also making any appropriate #requestLayout() or invalidate() calls. For example, callers can post a Runnable which performs a #requestLayout() on the next frame, after all detach/attach calls are finished, causing layout to be run prior to redrawing the view hierarchy.

This method should be called only for views which were detached from their parent.

Parameters
child View!: the child to attach
index Int: the index at which the child should be attached
params ViewGroup.LayoutParams!: the layout parameters of the child

canAnimate

Added in API level 1
protected open fun canAnimate(): Boolean

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

Return
Boolean true if the children can be animated, false otherwise

checkLayoutParams

Added in API level 1
protected open fun checkLayoutParams(p: ViewGroup.LayoutParams!): Boolean

cleanupLayoutState

Added in API level 1
protected open fun cleanupLayoutState(child: View!): Unit

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

Parameters
child View!: the child on which to perform the cleanup

debug

Added in API level 1
protected open fun debug(depth: Int): Unit

detachAllViewsFromParent

Added in API level 1
protected open fun detachAllViewsFromParent(): Unit

Detaches all views from the parent. Detaching a view should be followed either by a call to attachViewToParent(android.view.View,int,android.view.ViewGroup.LayoutParams) or a call to removeDetachedView(android.view.View,boolean). Detachment should only be temporary; reattachment or removal should happen within the same drawing cycle as detachment. When a view is detached, its parent is null and cannot be retrieved by a call to getChildAt(int).

detachViewFromParent

Added in API level 1
protected open fun detachViewFromParent(child: View!): Unit

Detaches a view from its parent. Detaching a view should be followed either by a call to attachViewToParent(android.view.View,int,android.view.ViewGroup.LayoutParams) or a call to removeDetachedView(android.view.View,boolean). Detachment should only be temporary; reattachment or removal should happen within the same drawing cycle as detachment. When a view is detached, its parent is null and cannot be retrieved by a call to getChildAt(int).

Parameters
child View!: the child to detach

detachViewFromParent

Added in API level 1
protected open fun detachViewFromParent(index: Int): Unit

Detaches a view from its parent. Detaching a view should be followed either by a call to attachViewToParent(android.view.View,int,android.view.ViewGroup.LayoutParams) or a call to removeDetachedView(android.view.View,boolean). Detachment should only be temporary; reattachment or removal should happen within the same drawing cycle as detachment. When a view is detached, its parent is null and cannot be retrieved by a call to getChildAt(int).

Parameters
index Int: the index of the child to detach

detachViewsFromParent

Added in API level 1
protected open fun detachViewsFromParent(
    start: Int,
    count: Int
): Unit

Detaches a range of views from their parents. Detaching a view should be followed either by a call to attachViewToParent(android.view.View,int,android.view.ViewGroup.LayoutParams) or a call to removeDetachedView(android.view.View,boolean). Detachment should only be temporary; reattachment or removal should happen within the same drawing cycle as detachment. When a view is detached, its parent is null and cannot be retrieved by a call to getChildAt(int).

Parameters
start Int: the first index of the childrend range to detach
count Int: the number of children to detach

dispatchDraw

Added in API level 1
protected open fun dispatchDraw(canvas: Canvas): Unit

Called by draw to draw the child views. This may be overridden by derived classes to gain control just before its children are drawn (but after its own view has been drawn).

Parameters
canvas Canvas: This value cannot be null.

dispatchFreezeSelfOnly

Added in API level 1
protected open fun dispatchFreezeSelfOnly(container: SparseArray<Parcelable!>!): Unit

Perform dispatching of a saveHierarchyState(android.util.SparseArray) freeze()} to only this view, not to its children. For use when overriding dispatchSaveInstanceState(android.util.SparseArray) dispatchFreeze()} to allow subclasses to freeze their own state but not the state of their children.

Parameters
container SparseArray<Parcelable!>!: the container

dispatchGenericFocusedEvent

Added in API level 14
protected open fun dispatchGenericFocusedEvent(event: MotionEvent!): Boolean
Parameters
event MotionEvent!: The motion event to be dispatched.
Return
Boolean True if the event was handled by the view, false otherwise.

dispatchGenericPointerEvent

Added in API level 14
protected open fun dispatchGenericPointerEvent(event: MotionEvent!): Boolean
Parameters
event MotionEvent!: The motion event to be dispatched.
Return
Boolean True if the event was handled by the view, false otherwise.

dispatchHoverEvent

Added in API level 14
protected open fun dispatchHoverEvent(event: MotionEvent!): Boolean
Parameters
event MotionEvent!: The motion event to be dispatched.
Return
Boolean True if the event was handled by the view, false otherwise.

dispatchRestoreInstanceState

Added in API level 1
protected open fun dispatchRestoreInstanceState(container: SparseArray<Parcelable!>!): Unit
Parameters
container SparseArray<Parcelable!>!: The SparseArray which holds previously saved state.

dispatchSaveInstanceState

Added in API level 1
protected open fun dispatchSaveInstanceState(container: SparseArray<Parcelable!>!): Unit
Parameters
container SparseArray<Parcelable!>!: The SparseArray in which to save the view's state.

dispatchSetPressed

Added in API level 1
protected open fun dispatchSetPressed(pressed: Boolean): Unit
Parameters
pressed Boolean: The new pressed state

dispatchThawSelfOnly

Added in API level 1
protected open fun dispatchThawSelfOnly(container: SparseArray<Parcelable!>!): Unit

Perform dispatching of a restoreHierarchyState(android.util.SparseArray) to only this view, not to its children. For use when overriding dispatchRestoreInstanceState(android.util.SparseArray) to allow subclasses to thaw their own state but not the state of their children.

Parameters
container SparseArray<Parcelable!>!: the container

dispatchVisibilityChanged

Added in API level 8
protected open fun dispatchVisibilityChanged(
    changedView: View,
    visibility: Int
): Unit
Parameters
changedView View: The view whose visibility changed. Could be 'this' or an ancestor view. This value cannot be null.
visibility Int: The new visibility of changedView: VISIBLE, INVISIBLE or GONE. Value is android.view.View#VISIBLE, android.view.View#INVISIBLE, or android.view.View#GONE

drawChild

Added in API level 1
protected open fun drawChild(
    canvas: Canvas,
    child: View!,
    drawingTime: Long
): Boolean

Draw one child of this View Group. This method is responsible for getting the canvas in the right state. This includes clipping, translating so that the child's scrolled origin is at 0, 0, and applying any animation transformations.

Parameters
canvas Canvas: The canvas on which to draw the child This value cannot be null.
child View!: Who to draw
drawingTime Long: The time at which draw is occurring
Return
Boolean True if an invalidate() was issued

drawableStateChanged

Added in API level 1
protected open fun drawableStateChanged(): Unit

generateDefaultLayoutParams

Added in API level 1
protected open fun generateDefaultLayoutParams(): ViewGroup.LayoutParams!

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.

Return
ViewGroup.LayoutParams! a set of default layout parameters or null

generateLayoutParams

Added in API level 1
protected open fun generateLayoutParams(p: ViewGroup.LayoutParams!): ViewGroup.LayoutParams!

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
p ViewGroup.LayoutParams!: The layout parameters to convert into a suitable set of layout parameters for this ViewGroup.
Return
ViewGroup.LayoutParams! an instance of android.view.ViewGroup.LayoutParams or one of its descendants

getChildDrawingOrder

Added in API level 1
protected open fun getChildDrawingOrder(
    childCount: Int,
    drawingPosition: Int
): Int

Converts drawing order position to container position. Override this if you want to change the drawing order of children. By default, it returns drawingPosition.

NOTE: In order for this method to be called, you must enable child ordering first by calling setChildrenDrawingOrderEnabled(boolean).

Parameters
drawingPosition Int: the drawing order position.
Return
Int the container position of a child for this drawing order position.

getChildStaticTransformation

Added in API level 1
protected open fun getChildStaticTransformation(
    child: View!,
    t: Transformation!
): Boolean

Sets t to be the static transformation of the child, if set, returning a boolean to indicate whether a static transform was set. The default implementation simply returns false; subclasses may override this method for different behavior. setStaticTransformationsEnabled(boolean) must be set to true for this method to be called.

Parameters
child View!: The child view whose static transform is being requested
t Transformation!: The Transformation which will hold the result
Return
Boolean true if the transformation was set, false otherwise

isChildrenDrawingOrderEnabled

Added in API level 7
protected open fun isChildrenDrawingOrderEnabled(): Boolean

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

Return
Boolean true if children drawing order is defined by getChildDrawingOrder(int,int), false otherwise

isChildrenDrawnWithCacheEnabled

Added in API level 1
Deprecated in API level 23
protected open fun isChildrenDrawnWithCacheEnabled(): Boolean

Deprecated: As of android.os.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.

Indicates whether the ViewGroup is currently drawing its children using their drawing cache.

Return
Boolean true if children should be drawn with their cache, false otherwise

measureChild

Added in API level 1
protected open fun measureChild(
    child: View!,
    parentWidthMeasureSpec: Int,
    parentHeightMeasureSpec: Int
): Unit

Ask one of the children of this view to measure itself, taking into account both the MeasureSpec requirements for this view and its padding. The heavy lifting is done in getChildMeasureSpec.

Parameters
child View!: The child to measure
parentWidthMeasureSpec Int: The width requirements for this view
parentHeightMeasureSpec Int: The height requirements for this view

measureChildWithMargins

Added in API level 1
protected open fun measureChildWithMargins(
    child: View!,
    parentWidthMeasureSpec: Int,
    widthUsed: Int,
    parentHeightMeasureSpec: Int,
    heightUsed: Int
): Unit

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. The child must have MarginLayoutParams The heavy lifting is done in getChildMeasureSpec.

Parameters
child View!: The child to measure
parentWidthMeasureSpec Int: The width requirements for this view
widthUsed Int: Extra space that has been used up by the parent horizontally (possibly by other children of the parent)
parentHeightMeasureSpec Int: The height requirements for this view
heightUsed Int: Extra space that has been used up by the parent vertically (possibly by other children of the parent)

measureChildren

Added in API level 1
protected open fun measureChildren(
    widthMeasureSpec: Int,
    heightMeasureSpec: Int
): Unit

Ask all of the children of this view to measure themselves, taking into account both the MeasureSpec requirements for this view and its padding. We skip children that are in the GONE state The heavy lifting is done in getChildMeasureSpec.

Parameters
widthMeasureSpec Int: The width requirements for this view
heightMeasureSpec Int: The height requirements for this view

onAttachedToWindow

Added in API level 1
protected open fun onAttachedToWindow(): Unit

onCreateDrawableState

Added in API level 1
protected open fun onCreateDrawableState(extraSpace: Int): IntArray!
Parameters
extraSpace Int: if non-zero, this is the number of extra entries you would like in the returned array in which you can place your own states.
Return
IntArray! Returns an array holding the current Drawable state of the view.

onDetachedFromWindow

Added in API level 1
protected open fun onDetachedFromWindow(): Unit

onLayout

Added in API level 1
protected abstract fun onLayout(
    changed: Boolean,
    l: Int,
    t: Int,
    r: Int,
    b: Int
): Unit
Parameters
changed Boolean: This is a new size or position for this view
left Left position, relative to parent
top Top position, relative to parent
right Right position, relative to parent
bottom Bottom position, relative to parent

onRequestFocusInDescendants

Added in API level 1
protected open fun onRequestFocusInDescendants(
    direction: Int,
    previouslyFocusedRect: Rect!
): Boolean

Look for a descendant to call android.view.View#requestFocus on. Called by ViewGroup.requestFocus(int, android.graphics.Rect) when it wants to request focus within its children. Override this to customize how your ViewGroup requests focus within its children.

Parameters
direction Int: One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT
previouslyFocusedRect Rect!: The rectangle (in this View's coordinate system) to give a finer grained hint about where focus is coming from. May be null if there is no hint.
Return
Boolean Whether focus was taken.

removeDetachedView

Added in API level 1
protected open fun removeDetachedView(
    child: View!,
    animate: Boolean
): Unit

Finishes the removal of a detached view. This method will dispatch the detached from window event and notify the hierarchy change listener.

This method is intended to be lightweight and makes no assumptions about whether the parent or child should be redrawn. Proper use of this method will include also making any appropriate #requestLayout() or invalidate() calls. For example, callers can post a Runnable which performs a #requestLayout() on the next frame, after all detach/remove calls are finished, causing layout to be run prior to redrawing the view hierarchy.

Parameters
child View!: the child to be definitely removed from the view hierarchy
animate Boolean: if true and the view has an animation, the view is placed in the disappearing views list, otherwise, it is detached from the window

setChildrenDrawingCacheEnabled

Added in API level 1
Deprecated in API level 28
protected open fun setChildrenDrawingCacheEnabled(enabled: Boolean): Unit

Deprecated: 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 android.graphics.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.

Enables or disables the drawing cache for each child of this view group.

Parameters
enabled Boolean: true to enable the cache, false to dispose of it

setChildrenDrawingOrderEnabled

Added in API level 7
protected open fun setChildrenDrawingOrderEnabled(enabled: Boolean): Unit

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

Note that Z reordering, done by dispatchDraw(android.graphics.Canvas), will override custom child ordering done via this method.

Parameters
enabled Boolean: true if the order of the children when drawing is determined by getChildDrawingOrder(int,int), false otherwise

setChildrenDrawnWithCacheEnabled

Added in API level 1
Deprecated in API level 23
protected open fun setChildrenDrawnWithCacheEnabled(enabled: Boolean): Unit

Deprecated: As of android.os.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.

Tells the ViewGroup to draw its children using their drawing cache. This property is ignored when isAlwaysDrawnWithCacheEnabled() is true. A child's drawing cache will be used only if it has been enabled. Subclasses should call this method to start and stop using the drawing cache when they perform performance sensitive operations, like scrolling or animating.

Parameters
enabled Boolean: true if children should be drawn with their cache, false otherwise

setStaticTransformationsEnabled

Added in API level 3
protected open fun setStaticTransformationsEnabled(enabled: Boolean): Unit

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. Any subclass overriding getChildStaticTransformation(android.view.View,android.view.animation.Transformation) should set this property to true.

Parameters
enabled Boolean: True to enable static transformations on children, false otherwise.