Android 12 Developer Preview is here! Try it out, and give us your feedback!

ViewGroupCompat

class ViewGroupCompat
kotlin.Any
   ↳ androidx.core.view.ViewGroupCompat

Helper for accessing features in ViewGroup.

Summary

Constants
static Int

This constant is a layoutMode.

static Int

This constant is a layoutMode.

Public methods
static Int
getLayoutMode(@NonNull group: ViewGroup)

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

static Int
getNestedScrollAxes(@NonNull group: ViewGroup)

Return the current axes of nested scrolling for this ViewGroup.

static Boolean
isTransitionGroup(@NonNull group: ViewGroup)

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

static Boolean

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

static Unit
setLayoutMode(@NonNull group: ViewGroup, mode: Int)

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

static Unit

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

static Unit
setTransitionGroup(@NonNull group: ViewGroup, isTransitionGroup: Boolean)

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

Constants

LAYOUT_MODE_CLIP_BOUNDS

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

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

Public methods

getLayoutMode

static fun getLayoutMode(@NonNull group: ViewGroup): 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

getNestedScrollAxes

static fun getNestedScrollAxes(@NonNull group: ViewGroup): Int

Return the current axes of nested scrolling for this ViewGroup.

A ViewGroup returning something other than ViewCompat#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

isTransitionGroup

static fun isTransitionGroup(@NonNull group: ViewGroup): 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.

onRequestSendAccessibilityEvent

static fun onRequestSendAccessibilityEvent(
    group: ViewGroup!,
    child: View!,
    event: AccessibilityEvent!
): Boolean

Deprecated: Use ViewGroup#onRequestSendAccessibilityEvent(View, AccessibilityEvent) directly.

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

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

Parameters
group ViewGroup!: The group whose method to invoke.
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.