ViewGroup
abstract class ViewGroup : View, ViewParent, ViewManager
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 |
static Int |
This constant is a |
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!, attrs: AttributeSet!) |
|
ViewGroup(context: Context!, attrs: AttributeSet!, defStyleAttr: Int) |
|
ViewGroup(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int) |
Public methods | |
---|---|
open Unit |
addChildrenForAccessibility(outChildren: ArrayList<View!>!) |
open Unit |
addExtraDataToAccessibilityNodeInfo(info: AccessibilityNodeInfo, extraDataKey: String, arguments: Bundle?) Adds extra data to an |
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 |
addTouchables(views: ArrayList<View!>!) |
open Unit |
Adds a child view. |
open Unit |
Adds a child view. |
open Unit |
Adds a child view with this ViewGroup's default layout parameters and the specified width and height. |
open Unit |
addView(child: View!, params: ViewGroup.LayoutParams!) Adds a child view with the specified layout parameters. |
open Unit |
addView(child: View!, index: Int, params: ViewGroup.LayoutParams!) Adds a child view with the specified layout parameters. |
open Unit |
bringChildToFront(child: View!) |
open Unit |
childDrawableStateChanged(child: View) If |
open Unit |
childHasTransientStateChanged(child: View, childHasTransientState: Boolean) Called when a child view has changed whether or not it is tracking transient state. |
open Unit |
clearChildFocus(child: View!) |
open Unit |
Removes any pending animations for views that have been removed. |
open Unit | |
open WindowInsets! |
dispatchApplyWindowInsets(insets: WindowInsets!) |
open Boolean |
dispatchCapturedPointerEvent(event: MotionEvent!) |
open Unit |
dispatchConfigurationChanged(newConfig: Configuration!) |
open Unit |
dispatchCreateViewTranslationRequest(viewIds: MutableMap<AutofillId!, LongArray!>, supportedFormats: IntArray, capability: TranslationCapability!, requests: MutableList<ViewTranslationRequest!>) Dispatch to collect the |
open Unit |
dispatchDisplayHint(hint: Int) |
open Boolean |
dispatchDragEvent(event: DragEvent!) |
open Unit |
dispatchDrawableHotspotChanged(x: Float, y: Float) Dispatches drawable hotspot changes to child views that meet at least one of the following criteria:
|
open Boolean |
dispatchKeyEvent(event: KeyEvent!) |
open Boolean |
dispatchKeyEventPreIme(event: KeyEvent!) |
open Boolean |
dispatchKeyShortcutEvent(event: KeyEvent!) |
open Unit |
dispatchPointerCaptureChanged(hasCapture: Boolean) |
open Unit |
dispatchProvideAutofillStructure(structure: ViewStructure, flags: Int) Dispatches creation of a |
open Unit |
dispatchProvideStructure(structure: ViewStructure!) Dispatch creation of |
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 |
dispatchSetActivated(activated: Boolean) |
open Unit |
dispatchSetSelected(selected: Boolean) |
open Unit |
dispatchSystemUiVisibilityChanged(visible: Int) |
open Boolean | |
open Boolean |
dispatchTrackballEvent(event: MotionEvent!) |
open Boolean |
dispatchUnhandledMove(focused: View!, direction: Int) |
open Unit |
dispatchWindowFocusChanged(hasFocus: Boolean) |
open Unit |
Dispatches |
open Unit |
Dispatches |
open WindowInsets |
dispatchWindowInsetsAnimationProgress(insets: WindowInsets, runningAnimations: MutableList<WindowInsetsAnimation!>) Dispatches |
open WindowInsetsAnimation.Bounds |
dispatchWindowInsetsAnimationStart(animation: WindowInsetsAnimation, bounds: WindowInsetsAnimation.Bounds) Dispatches |
open Unit |
dispatchWindowSystemUiVisiblityChanged(visible: Int) |
open Unit |
dispatchWindowVisibilityChanged(visibility: Int) |
open Unit |
endViewTransition(view: View!) This method should always be called following an earlier call to |
open View! | |
open OnBackInvokedDispatcher? |
findOnBackInvokedDispatcherForChild(child: View, requester: View) Walk up the View hierarchy to find the nearest |
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 |
gatherTransparentRegion(region: Region?) |
open ViewGroup.LayoutParams! |
generateLayoutParams(attrs: AttributeSet!) 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 |
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 |
hasFocus() 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 |
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 | |
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 |
onInterceptHoverEvent(event: MotionEvent!) 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 |
onNestedPrePerformAccessibilityAction(target: View, action: Int, args: Bundle?) 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 | |
open Unit |
onNestedScrollAccepted(child: View, target: View, axes: Int) |
open Boolean |
onRequestSendAccessibilityEvent(child: View!, event: AccessibilityEvent!) Called when a child has requested sending an |
open PointerIcon! |
onResolvePointerIcon(event: MotionEvent!, pointerIndex: Int) |
open Boolean |
onStartNestedScroll(child: View, target: View, nestedScrollAxes: Int) |
open Unit |
onStopNestedScroll(child: View) |
open Unit |
onViewAdded(child: View!) Called when a new child is added to this ViewGroup. |
open Unit |
onViewRemoved(child: View!) Called when a child view is removed from this ViewGroup. |
open Unit |
recomputeViewAttributes(child: View!) |
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 |
open Unit |
removeViewAt(index: Int) Removes the view at the specified position in the group. |
open Unit |
removeViewInLayout(view: View!) 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 |
requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) |
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 |
requestSendAccessibilityEvent(child: View, event: AccessibilityEvent!) |
open Unit |
requestTransparentRegion(child: View!) |
open Boolean | |
open Unit |
Schedules the layout animation to be played after the next layout pass of this view group. |
open Unit |
setAddStatesFromChildren(addsStates: Boolean) Sets whether this ViewGroup's drawable states also include its children's drawable states. |
open Unit |
setAlwaysDrawnWithCacheEnabled(always: Boolean) Indicates whether this ViewGroup will always try to draw its children using their drawing cache. |
open Unit |
setAnimationCacheEnabled(enabled: Boolean) 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 |
setDescendantFocusability(focusability: Int) Set the descendant focusability of this view group. |
open Unit |
setLayoutAnimation(controller: LayoutAnimationController!) Sets the layout animation controller used to animate the group's children after the first layout. |
open Unit |
setLayoutAnimationListener(animationListener: Animation.AnimationListener!) 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 |
setLayoutTransition(transition: LayoutTransition!) 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 |
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 |
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 |
startViewTransition(view: View!) This method tells the ViewGroup that the given View object, which should have this ViewGroup as its parent, should be kept around (re-displayed when the ViewGroup draws its children) even if it is removed from its parent. |
open Unit |
suppressLayout(suppress: Boolean) Tells this ViewGroup to suppress all layout() calls until layout suppression is disabled with a later call to suppressLayout(false). |
open Unit |
updateViewLayout(view: View!, params: ViewGroup.LayoutParams!) |
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 |
cleanupLayoutState(child: View!) Prevents the specified child to be laid out during the next layout pass. |
open Unit | |
open Unit |
Detaches all views from the parent. |
open Unit |
detachViewFromParent(child: View!) Detaches a view from its parent. |
open Unit |
detachViewFromParent(index: Int) Detaches a view from its parent. |
open Unit |
detachViewsFromParent(start: Int, count: Int) Detaches a range of views from their parents. |
open Unit |
dispatchDraw(canvas: Canvas) Called by draw to draw the child views. |
open Unit |
dispatchFreezeSelfOnly(container: SparseArray<Parcelable!>!) Perform dispatching of a |
open Boolean |
dispatchGenericFocusedEvent(event: MotionEvent!) |
open Boolean |
dispatchGenericPointerEvent(event: MotionEvent!) |
open Boolean |
dispatchHoverEvent(event: MotionEvent!) |
open Unit |
dispatchRestoreInstanceState(container: SparseArray<Parcelable!>!) |
open Unit |
dispatchSaveInstanceState(container: SparseArray<Parcelable!>!) |
open Unit |
dispatchSetPressed(pressed: Boolean) |
open Unit |
dispatchThawSelfOnly(container: SparseArray<Parcelable!>!) Perform dispatching of a |
open Unit |
dispatchVisibilityChanged(changedView: View, visibility: Int) |
open Boolean |
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 |
getChildStaticTransformation(child: View!, t: Transformation!) Sets |
open Boolean |
Indicates whether the ViewGroup is drawing its children in the order defined by |
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! |
onCreateDrawableState(extraSpace: Int) |
open Unit | |
abstract Unit | |
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 |
setChildrenDrawingCacheEnabled(enabled: Boolean) Enables or disables the drawing cache for each child of this view group. |
open Unit |
setChildrenDrawingOrderEnabled(enabled: Boolean) Tells the ViewGroup whether to draw its children in the order defined by the method |
open Unit |
setChildrenDrawnWithCacheEnabled(enabled: Boolean) Tells the ViewGroup to draw its children using their drawing cache. |
open Unit |
setStaticTransformationsEnabled(enabled: Boolean) When this property is set to true, this ViewGroup supports static transformations on children; this causes |
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
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
static val FOCUS_AFTER_DESCENDANTS: Int
This view will get focus only if none of its descendants want it.
Value: 262144
FOCUS_BEFORE_DESCENDANTS
static val FOCUS_BEFORE_DESCENDANTS: Int
This view will get focus before any of its descendants.
Value: 131072
FOCUS_BLOCK_DESCENDANTS
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
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
PERSISTENT_ALL_CACHES
static valPERSISTENT_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
static valPERSISTENT_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
static valPERSISTENT_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
static valPERSISTENT_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
ViewGroup(
context: Context!,
attrs: AttributeSet!,
defStyleAttr: Int)
ViewGroup
ViewGroup(
context: Context!,
attrs: AttributeSet!,
defStyleAttr: Int,
defStyleRes: Int)
Public methods
addChildrenForAccessibility
open fun addChildrenForAccessibility(outChildren: ArrayList<View!>!): Unit
Parameters | |
---|---|
outChildren |
ArrayList<View!>!: The output list that will receive children for accessibility. |
addExtraDataToAccessibilityNodeInfo
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
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
open fun addKeyboardNavigationClusters(
: MutableCollection<View!>,
: Int
): Unit
Parameters | |
---|---|
views |
MutableCollection<View!>: Keyboard navigation cluster roots found so far This value cannot be null . |
direction |
Int: Direction to look |
addStatesFromChildren
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
open fun addTouchables(views: ArrayList<View!>!): Unit
Parameters | |
---|---|
views |
ArrayList<View!>!: Touchable views found so far |
addView
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 |
See Also
addView
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 |
See Also
addView
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 |
addView
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
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 |
bringChildToFront
open fun bringChildToFront(child: View!): Unit
Parameters | |
---|---|
child |
View!: The child to bring to the top of the z order |
childDrawableStateChanged
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
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
open fun clearChildFocus(child: View!): Unit
Parameters | |
---|---|
child |
View!: The view that is giving up focus |
clearDisappearingChildren
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.
dispatchApplyWindowInsets
open fun dispatchApplyWindowInsets(insets: WindowInsets!): WindowInsets!
Parameters | |
---|---|
insets |
WindowInsets!: Insets to apply |
Return | |
---|---|
WindowInsets! |
The provided insets minus the insets that were consumed |
dispatchCapturedPointerEvent
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
open fun dispatchConfigurationChanged(newConfig: Configuration!): Unit
Parameters | |
---|---|
newConfig |
Configuration!: The new resource configuration. |
dispatchCreateViewTranslationRequest
open fun dispatchCreateViewTranslationRequest(
viewIds: MutableMap<AutofillId!, LongArray!>,
supportedFormats: IntArray,
capability: TranslationCapability!,
requests: MutableList<ViewTranslationRequest!>
): Unit
Dispatch to collect the ViewTranslationRequest
s 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 ViewTranslationRequest
s and create a android.view.translation.Translator
to translate the requests. All the ViewTranslationRequest
s 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.
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
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 |
dispatchDrawableHotspotChanged
open fun dispatchDrawableHotspotChanged(
x: Float,
y: Float
): Unit
Dispatches drawable hotspot changes to child views that meet at least one of the following criteria:
- Returns
false
from bothView#isClickable()
andView#isLongClickable()
- Requests duplication of parent state via
View#setDuplicateParentStateEnabled(boolean)
Parameters | |
---|---|
x |
Float: hotspot x coordinate |
y |
Float: hotspot y coordinate |
dispatchKeyEvent
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
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
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
open fun dispatchPointerCaptureChanged(hasCapture: Boolean): Unit
dispatchProvideAutofillStructure
open fun dispatchProvideAutofillStructure(
structure: ViewStructure,
flags: Int
): Unit
Dispatches creation of a ViewStructure
s 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:
- Sets the
AutofillId
in the structure. - Calls
onProvideAutofillStructure(android.view.ViewStructure,int)
. - Calls
onProvideAutofillVirtualStructure(android.view.ViewStructure,int)
.
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 theAutofillId
in the structure (for example, by callingstructure.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 whatisImportantForAutofill()
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
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
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
open fun dispatchSetActivated(activated: Boolean): Unit
Parameters | |
---|---|
activated |
Boolean: The new activated state |
dispatchSetSelected
open fun dispatchSetSelected(selected: Boolean): Unit
Parameters | |
---|---|
selected |
Boolean: The new selected state |
dispatchSystemUiVisibilityChanged
open fundispatchSystemUiVisibilityChanged(visible: Int): Unit
Deprecated: Deprecated in Java.
dispatchTouchEvent
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
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
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
open fun dispatchWindowFocusChanged(hasFocus: Boolean): Unit
Parameters | |
---|---|
hasFocus |
Boolean: True if the window containing this view now has focus, false otherwise. |
dispatchWindowInsetsAnimationEnd
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
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
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
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
open fundispatchWindowSystemUiVisiblityChanged(visible: Int): Unit
Deprecated: Deprecated in Java.
dispatchWindowVisibilityChanged
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
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
open fun findFocus(): View!
Return | |
---|---|
View! |
The view that currently has focus, or null if no focused view can be found. |
findOnBackInvokedDispatcherForChild
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
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
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
open fun focusableViewAvailable(v: View!): Unit
Parameters | |
---|---|
v |
View!: The view that has become newly focusable |
gatherTransparentRegion
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
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 |
getChildAt
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
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
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. |
See Also
getChildMeasureSpec
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
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
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. |
See Also
getClipToPadding
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
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
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
open fun getLayoutAnimation(): LayoutAnimationController!
Returns the layout animation controller used to animate the group's children.
Return | |
---|---|
LayoutAnimationController! |
the current animation controller |
getLayoutAnimationListener
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
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 |
See Also
getLayoutTransition
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
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
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. |
See Also
getPersistentDrawingCache
open fungetPersistentDrawingCache(): 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
open fun getTouchscreenBlocksFocus(): Boolean
Check whether this ViewGroup should ignore focus requests for itself and its children.
hasFocus
open fun hasFocus(): Boolean
Returns true if this view has or contains focus
Return | |
---|---|
Boolean |
true if this view has or contains focus |
hasTransientState
open fun hasTransientState(): Boolean
Return | |
---|---|
Boolean |
true if the view has transient state |
indexOfChild
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
funinvalidateChild(
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
open funinvalidateChildInParent(
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
open funisAlwaysDrawnWithCacheEnabled(): 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
open funisAnimationCacheEnabled(): 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
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
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
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. |
layout
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
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
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
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
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
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
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:
- You will receive the down event here.
- 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.
- 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().
- 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
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
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
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
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
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
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
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
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
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
open fun onStopNestedScroll(child: View): Unit
Parameters | |
---|---|
target |
View that initiated the nested scroll This value cannot be null . |
onViewAdded
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
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 |
recomputeViewAttributes
open fun recomputeViewAttributes(child: View!): Unit
Parameters | |
---|---|
child |
View!: View whose attributes have changed. |
removeAllViews
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
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
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
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
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
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
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
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
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
open fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean): Unit
Parameters | |
---|---|
disallowIntercept |
Boolean: True if the child does not want the parent to intercept touch events. |
requestFocus
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
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
open fun requestTransparentRegion(child: View!): Unit
Parameters | |
---|---|
child |
View!: the view requesting the transparent region computation |
restoreDefaultFocus
open fun restoreDefaultFocus(): Boolean
Return | |
---|---|
Boolean |
Whether this view or one of its descendants actually took focus |
scheduleLayoutAnimation
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
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
open funsetAlwaysDrawnWithCacheEnabled(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
open funsetAnimationCacheEnabled(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
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
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
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
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
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
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
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
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
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
open funsetPersistentDrawingCache(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 |
setTouchscreenBlocksFocus
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
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
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
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
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
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
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
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
open fun startLayoutAnimation(): Unit
Runs the layout animation. Calling this method triggers a relayout of this view group.
startViewTransition
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
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
open fun updateViewLayout(
view: View!,
params: ViewGroup.LayoutParams!
): Unit
Protected methods
addViewInLayout
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
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
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
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
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
protected open fun checkLayoutParams(p: ViewGroup.LayoutParams!): Boolean
cleanupLayoutState
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 |
detachAllViewsFromParent
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
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
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
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
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
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
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
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
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
protected open fun dispatchRestoreInstanceState(container: SparseArray<Parcelable!>!): Unit
Parameters | |
---|---|
container |
SparseArray<Parcelable!>!: The SparseArray which holds previously saved state. |
dispatchSaveInstanceState
protected open fun dispatchSaveInstanceState(container: SparseArray<Parcelable!>!): Unit
Parameters | |
---|---|
container |
SparseArray<Parcelable!>!: The SparseArray in which to save the view's state. |
dispatchSetPressed
protected open fun dispatchSetPressed(pressed: Boolean): Unit
Parameters | |
---|---|
pressed |
Boolean: The new pressed state |
dispatchThawSelfOnly
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
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
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 |
generateDefaultLayoutParams
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
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
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
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
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
protected open funisChildrenDrawnWithCacheEnabled(): 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
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
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
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 |
onCreateDrawableState
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. |
onLayout
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
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
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
protected open funsetChildrenDrawingCacheEnabled(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
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
protected open funsetChildrenDrawnWithCacheEnabled(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
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. |