Class ViewGroup
- All Implemented Interfaces:
Drawable.Callback
,ViewManager
,ViewParent
- Direct Known Subclasses:
AbsoluteLayout
,AdapterView
,CoordinatorLayout
,FrameLayout
,GridLayout
,LinearLayout
,RelativeLayout
,ViewPager
,WindowGroup
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
ViewGroup.LayoutParams
class which serves as the base
class for layouts parameters.
Also see ViewGroup.LayoutParams
for layout attributes.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
LayoutParams are used by views to tell their parents how they want to be laid out.static class
Per-child layout information for layouts that support margins.Nested classes/interfaces inherited from class icyllis.modernui.view.View
View.DragShadow, View.Focusable, View.FocusableMode, View.FocusDirection, View.FocusRealDirection, View.LayoutDir, View.NestedScrollType, View.OnAttachStateChangeListener, View.OnClickListener, View.OnContextClickListener, View.OnCreateContextMenuListener, View.OnDragListener, View.OnFocusChangeListener, View.OnGenericMotionListener, View.OnHoverListener, View.OnKeyListener, View.OnLayoutChangeListener, View.OnLongClickListener, View.OnScrollChangeListener, View.OnTouchListener, View.ResolvedLayoutDir, View.ScrollAxis, View.ScrollBarStyle, View.ScrollIndicators, View.TextAlignment, View.Visibility
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final int
We clip to padding when FLAG_CLIP_TO_PADDING and FLAG_PADDING_NOT_NULL are set at the same time.protected static final int
When set, this ViewGroup should not intercept touch events.static final int
This view will get focus only if none of its descendants want it.static final int
This view will get focus before any of its descendants.static final int
This view will block any of its descendants from getting focus, even if they are focusable.Fields inherited from class icyllis.modernui.view.View
ALPHA, BOTTOM, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLE, FOCUSABLE_AUTO, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, HAPTIC_FEEDBACK_ENABLED, INVISIBLE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, LAYOUT_DIRECTION_UNDEFINED, LEFT, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mScrollX, mScrollY, NO_ID, NOT_FOCUSABLE, OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS, OVER_SCROLL_NEVER, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, RIGHT, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCROLL_AXIS_HORIZONTAL, SCROLL_AXIS_NONE, SCROLL_AXIS_VERTICAL, SCROLL_INDICATOR_BOTTOM, SCROLL_INDICATOR_END, SCROLL_INDICATOR_LEFT, SCROLL_INDICATOR_RIGHT, SCROLL_INDICATOR_START, SCROLL_INDICATOR_TOP, SCROLL_X, SCROLL_Y, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_GRAVITY, TEXT_ALIGNMENT_INHERIT, TEXT_ALIGNMENT_TEXT_END, TEXT_ALIGNMENT_TEXT_START, TEXT_ALIGNMENT_VIEW_END, TEXT_ALIGNMENT_VIEW_START, TEXT_DIRECTION_ANY_RTL, TEXT_DIRECTION_FIRST_STRONG, TEXT_DIRECTION_FIRST_STRONG_LTR, TEXT_DIRECTION_FIRST_STRONG_RTL, TEXT_DIRECTION_INHERIT, TEXT_DIRECTION_LOCALE, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, TOP, TRANSLATION_X, TRANSLATION_Y, TRANSLATION_Z, TYPE_NON_TOUCH, TYPE_TOUCH, VIEW_MARKER, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y, Z
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addFocusables
(ArrayList<View> views, int direction, int focusableMode) Adds any focusable views that are descendants of this view (possibly including this view if it is focusable itself) to views.void
addKeyboardNavigationClusters
(Collection<View> views, int direction) Adds any keyboard navigation cluster roots that are descendants of this view (possibly including this view if it is a cluster root itself) to views.boolean
Returns whether this ViewGroup's drawable states also include its children's drawable states.void
addTouchables
(ArrayList<View> views) Add any touchable views that are descendants of this view (possibly including this view if it is touchable itself) to views.void
addTransientView
(View view, int index) This method adds a view to this container at the specified index purely for the purposes of allowing that view to draw even though it is not a normal child of the container.void
Adds a child view.void
Adds a child view.void
Adds a child view with this ViewGroup's default layout parameters and the specified width and height.void
addView
(View child, int index, ViewGroup.LayoutParams params) Adds a child view with the specified layout parameters.void
addView
(View child, ViewGroup.LayoutParams params) Adds a child view with the specified layout parameters.protected boolean
addViewInLayout
(View child, int index, ViewGroup.LayoutParams params) Adds a view during layout.protected boolean
addViewInLayout
(View child, int index, ViewGroup.LayoutParams params, boolean preventRequestLayout) Adds a view during layout.protected void
attachViewToParent
(View child, int index, ViewGroup.LayoutParams params) Attaches a view to this view group.void
bringChildToFront
(View child) Change the z order of the child, so it's on top of all other children.protected boolean
Check whether given params fit to this view group.void
childDrawableStateChanged
(View child) IfaddStatesFromChildren()
is true, refreshes this group's drawable state (to include the states from its children).void
childHasTransientStateChanged
(View child, boolean childHasTransientState) Called when a child view has changed whether it is tracking transient state.protected void
cleanupLayoutState
(View child) Prevents the specified child to be laid out during the next layout pass.void
clearChildFocus
(View child) Called when a child of this parent is giving up focusvoid
Removes any pending animations for views that have been removed.void
Called when this view wants to give up focus.protected void
Detaches all views from the parent.protected void
detachViewFromParent
(int index) Detaches a view from its parent.protected void
detachViewFromParent
(View child) Detaches a view from its parent.protected void
detachViewsFromParent
(int start, int count) Detaches a range of views from their parents.protected void
dispatchDraw
(Canvas canvas) Draw the child views.void
dispatchDrawableHotspotChanged
(float x, float y) Dispatches drawable hotspot changes to child views that meet at least one of the following criteria: Returnsfalse
from bothView.isClickable()
andView.isLongClickable()
Requests duplication of parent state viaView.setDuplicateParentStateEnabled(boolean)
void
DispatchView.onFinishTemporaryDetach()
to this View and its direct children if this is a container View.protected boolean
Dispatch a generic motion event to the view under the first pointer.protected boolean
dispatchHoverEvent
(MotionEvent event) Dispatch a hover event.boolean
dispatchKeyEvent
(KeyEvent event) Dispatch a key event to the next view on the focus path.boolean
dispatchKeyShortcutEvent
(KeyEvent event) Dispatches a key shortcut event.void
dispatchSetActivated
(boolean activated) Dispatch setActivated to all of this View's children.protected void
dispatchSetPressed
(boolean pressed) Dispatch setPressed to all of this View's children.void
dispatchSetSelected
(boolean selected) Dispatch setSelected to all of this View's children.void
DispatchView.onStartTemporaryDetach()
to this View and its direct children if this is a container View.boolean
Pass the touch screen motion event down to the target view, or this view if it is the target.protected void
dispatchVisibilityChanged
(View changedView, int visibility) Dispatch a view visibility change down the view hierarchy.void
dispatchWindowFocusChanged
(boolean hasFocus) Called when the window containing this view gains or loses window focus.void
dispatchWindowVisibilityChanged
(int visibility) Dispatch a window visibility change down the view hierarchy.protected void
This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.protected void
Draw one child of this View Group.void
endViewTransition
(View view) This method should always be called following an earlier call tostartViewTransition(View)
.Find the view in the hierarchy rooted at this view that currently has focus.protected <T extends View>
TfindViewByPredicateTraversal
(Predicate<View> predicate, View childToSkip) protected <T extends View>
TfindViewTraversal
(int id) void
Tells the parent that a new focusable view has become available.focusSearch
(View focused, int direction) Find the nearest view in the specified direction that wants to take focus.protected ViewGroup.LayoutParams
Returns a set of default layout parameters.protected ViewGroup.LayoutParams
Returns a safe set of layout parameters based on the supplied layout params.getChildAt
(int index) Returns the view at the specified position in the group.int
Returns the number of children in the group.final int
getChildDrawingOrder
(int drawingPosition) Converts drawing order position to container position.protected int
getChildDrawingOrder
(int childCount, int drawingPosition) Converts drawing order position to container position.static int
getChildMeasureSpec
(int spec, int padding, int childDimension) Does the hard part of measureChildren: figuring out the MeasureSpec to pass to a particular child.boolean
getChildVisibleRect
(View child, Rect r, Point offset) Compute the visible part of a rectangular region defined in terms of a child view's coordinates.boolean
getChildVisibleRect
(View child, Rect r, Point offset, boolean forceParentCheck) boolean
Returns whether this group's children are clipped to their bounds before drawing.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.int
Gets the descendant focusability of this view group.Returns the focused child of this view, if any.Gets the LayoutTransition object for this ViewGroup.int
Return the current axes of nested scrolling for this NestedScrollingParent.boolean
Check whether this ViewGroup should ignore focus requests for itself and its children.getTransientView
(int position) Given a valid position within the list of transient views, returns the transient view at that position.int
Returns the number of transient views in this container.int
getTransientViewIndex
(int position) Given a valid position within the list of transient views, returns the index of the transient view at that position.protected boolean
hasBooleanFlag
(int flag) boolean
hasFocus()
Returns true if this view has or contains focusboolean
Indicates whether the view is currently tracking transient state that the app should not need to concern itself with saving and restoring, but that the framework should take special note to preserve when possible.int
indexOfChild
(View child) Returns the position in the group of the specified child view.protected void
internalSetPadding
(int left, int top, int right, int bottom) protected boolean
Indicates whether the ViewGroup is drawing its children in the order defined bygetChildDrawingOrder(int, int)
.boolean
Returns whether layout calls on this container are currently being suppressed, due to an earlier call tosuppressLayout(boolean)
.boolean
Returns true if this ViewGroup should be considered as a single entity for removal when executing an Activity transition.void
CallDrawable.jumpToCurrentState()
on all Drawable objects associated with this view.final void
layout
(int l, int t, int r, int b) Specifies the rectangle area of this view and all its descendants.protected void
measureChild
(View child, int parentWidthSpec, int parentHeightSpec) Ask one of the children of this view to measure itself, taking into account both the MeasureSpec requirements for this view and its padding.protected void
measureChildren
(int widthMeasureSpec, int heightMeasureSpec) Ask all the children of this view to measure themselves, taking into account both the MeasureSpec requirements for this view and its padding.protected void
measureChildWithMargins
(View child, int parentWidthSpec, int widthUsed, int parentHeightSpec, int heightUsed) Ask one of the children of this view to measure itself, taking into account both the MeasureSpec requirements for this view and its padding and margins.void
offsetChildrenTopAndBottom
(int offset) Offset the vertical location of all children of this view by the specified number of pixels.final void
offsetDescendantRectToMyCoords
(View descendant, Rect rect) Offset a rectangle that is in a descendant's coordinate space into our coordinate space.final void
offsetRectIntoDescendantCoords
(View descendant, Rect rect) Offset a rectangle that is in our coordinate space into an ancestor's coordinate space.protected void
onChildVisibilityChanged
(View child, int oldVisibility, int newVisibility) Called when a view's visibility has changed.protected int[]
onCreateDrawableState
(int extraSpace) Generate the newDrawable
state for this view.boolean
onInterceptHoverEvent
(MotionEvent event) Implement this method to intercept hover events before they are handled by child views.boolean
Implement this method to intercept all touch screen motion events.protected abstract void
onLayout
(boolean changed, int left, int top, int right, int bottom) Called fromView.layout(int, int, int, int)
when this view should assign a size and position to each of its children.boolean
onNestedFling
(View target, float velocityX, float velocityY, boolean consumed) Request a fling from a nested scroll.boolean
onNestedPreFling
(View target, float velocityX, float velocityY) React to a nested fling before the target view consumes it.void
onNestedPreScroll
(View target, int dx, int dy, int[] consumed, int type) React to a nested scroll in progress before the target view consumes a portion of the scroll.void
onNestedScroll
(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type, int[] consumed) React to a nested scroll in progress.void
onNestedScrollAccepted
(View child, View target, int axes, int type) React to the successful claiming of a nested scroll operation.protected boolean
onRequestFocusInDescendants
(int direction, Rect previouslyFocusedRect) Look for a descendant to callView.requestFocus()
on.onResolvePointerIcon
(MotionEvent event) Returns the pointer icon for the motion event, or null if it doesn't specify the icon.protected void
onSetLayoutParams
(View child, ViewGroup.LayoutParams layoutParams) boolean
onStartNestedScroll
(View child, View target, int axes, int type) React to a descendant view initiating a nestable scroll operation, claiming the nested scroll operation if appropriate.void
onStopNestedScroll
(View target, int type) React to a nested scroll operation ending.protected void
onViewAdded
(View child) Called when a new child is added to this ViewGroup.protected void
onViewRemoved
(View child) Called when a child view is removed from this ViewGroup.void
Call this method to remove all child views from the ViewGroup.void
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.protected void
removeDetachedView
(View child, boolean animate) Finishes the removal of a detached view.void
removeTransientView
(View view) Removes a view from the list of transient views in this container.void
removeView
(View view) Note: do not invoke this method fromView.draw(Canvas)
,View.onDraw(Canvas)
,dispatchDraw(Canvas)
or any related method.void
removeViewAt
(int index) Removes the view at the specified position in the group.void
removeViewInLayout
(View view) Removes a view during layout.void
removeViews
(int start, int count) Removes the specified range of views from the group.void
removeViewsInLayout
(int start, int count) Removes a range of views during layout.void
requestChildFocus
(View child, View focused) Called when a child of this parent wants focusboolean
requestChildRectangleOnScreen
(View child, Rect rectangle, boolean immediate) Called when a child of this group wants a particular rectangle to be positioned onto the screen.void
requestDisallowInterceptTouchEvent
(boolean disallowIntercept) Called when a child does not want this parent and its ancestors to intercept touch events withonInterceptTouchEvent(MotionEvent)
.boolean
requestFocus
(int direction, Rect previouslyFocusedRect) Call this to try to give focus to a specific view or to one of its descendants and give it hints about the direction and a specific rectangle that the focus is coming from.void
requestTransitionStart
(LayoutTransition transition) This method is called by LayoutTransition when there are 'changing' animations that need to start after the layout/setup phase.protected void
protected void
Resolve the Drawables depending on the layout direction.boolean
Resolve and cache the layout direction.void
Resolve the layout parameters depending on the resolved layout directionvoid
Resolves padding depending on layout direction, if applicable, and recomputes internal padding values to adjust for scroll bars.boolean
Resolve all RTL related properties.boolean
Resolve the text alignment.boolean
Resolve the text direction.boolean
Gives focus to the default-focus view in the view hierarchy that has this view as a root.void
setAddStatesFromChildren
(boolean addsStates) Sets whether this ViewGroup's drawable states also include its children's drawable states.protected void
setBooleanFlag
(int flag, boolean value) protected void
setChildrenDrawingOrderEnabled
(boolean enabled) Tells the ViewGroup whether to draw its children in the order defined by the methodgetChildDrawingOrder(int, int)
.void
setClipChildren
(boolean clipChildren) By default, children are clipped to their bounds before drawing.void
setClipToPadding
(boolean clipToPadding) Sets whether this ViewGroup will clip its children to its padding and resize (but not clip) any EdgeEffect to the padded region, if padding is present.void
setDescendantFocusability
(int focusability) Set the descendant focusability of this view group.void
setLayoutTransition
(LayoutTransition transition) Sets the LayoutTransition object for this ViewGroup.void
setTouchscreenBlocksFocus
(boolean touchscreenBlocksFocus) Set whether this ViewGroup should ignore focus requests for itself and its children.void
setTransitionGroup
(boolean isTransitionGroup) Changes whether or not this ViewGroup should be treated as a single entity during Activity Transitions.boolean
Return true if the pressed state should be delayed for children or descendants of this ViewGroup.boolean
showContextMenuForChild
(View originalView, float x, float y) Shows the context menu for the specified view or its ancestors anchored to the specified view-relative coordinate.startActionModeForChild
(View originalView, ActionMode.Callback callback, int type) Start an action mode of a specific type for the specified view.void
startViewTransition
(View view) This method tells the ViewGroup that the given View object, which should have this ViewGroup as its parent, should be kept around (re-displayed when the ViewGroup draws its children) even if it is removed from its parent.void
suppressLayout
(boolean suppress) Tells this ViewGroup to suppress all layout() calls until layout suppression is disabled with a later call to suppressLayout(false).protected void
transformPointToViewLocal
(float[] point, View child) void
updateViewLayout
(View view, ViewGroup.LayoutParams params) Methods inherited from class icyllis.modernui.view.View
addFocusables, addOnAttachStateChangeListener, addOnLayoutChangeListener, awakenScrollBars, awakenScrollBars, callOnClick, cancelLongPress, cancelPendingInputEvents, canReceivePointerEvents, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, combineMeasuredStates, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createContextMenu, dispatchGenericMotionEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPointerEvent, dp, draw, drawableHotspotChanged, findViewById, findViewByPredicate, findViewByPredicateInsideOut, focusSearch, forceHasOverlappingRendering, forceLayout, generateViewId, getAlpha, getAnimationMatrix, getBackground, getBaseline, getBottom, getBoundsOnScreen, getBoundsOnScreen, getContext, getContextMenuInfo, getDefaultSize, getDrawableState, getDrawingRect, getElevation, getFadingEdge, getFadingEdgeLength, getFocusable, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalScrollbarHeight, getHorizontalScrollbarThumbDrawable, getHorizontalScrollbarTrackDrawable, getId, getInverseMatrix, getKeyDispatcherState, getLayoutDirection, getLayoutParams, getLeft, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextClusterForwardId, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOnLongClickListener, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getPivotX, getPivotY, getRawLayoutDirection, getRawTextAlignment, getRawTextDirection, getRevealOnFocusHint, getRight, getRootView, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollIndicators, getScrollX, getScrollY, getStateListAnimator, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTextAlignment, getTextDirection, getTooltipText, getTooltipView, getTop, getTouchables, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getVerticalFadingEdgeLength, getVerticalScrollbarThumbDrawable, getVerticalScrollbarTrackDrawable, getVerticalScrollbarWidth, getViewRoot, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowVisibility, getX, getY, getZ, handleScrollBarDragging, hasExplicitFocusable, hasFocusable, hasIdentityMatrix, hasNestedScrollingParent, hasOnClickListeners, hasOnLongClickListeners, hasOverlappingRendering, hasTranslationTransientState, hasWindowFocus, invalidate, invalidateDrawable, isActivated, isAttachedToWindow, isClickable, isContextClickable, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isFocusedByDefault, isForegroundInsidePadding, isHapticFeedbackEnabled, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isInLayout, isInScrollingContainer, isInTouchMode, isKeyboardNavigationCluster, isLaidOut, isLayoutDirectionInherited, isLayoutDirectionResolved, isLayoutRequested, isLayoutRtl, isLongClickable, isNestedScrollingEnabled, isPaddingRelative, isPivotSet, isPressed, isRootNamespace, isScrollbarFadingEnabled, isSelected, isShowingLayoutBounds, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentInherited, isTextAlignmentResolved, isTextDirectionInherited, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVerticalScrollBarHidden, keyboardNavigationClusterSearch, mapRectFromViewToScreenCoords, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAttachedToWindow, onCancelPendingInputEvents, onCreateContextMenu, onDetachedFromWindow, onDragEvent, onDraw, onDrawForeground, onDrawScrollBars, onFinishTemporaryDetach, onFocusChanged, onGenericMotionEvent, onHoverChanged, onHoverEvent, onKeyDown, onKeyShortcut, onKeyUp, onMeasure, onOverScrolled, onResolveDrawables, onRtlPropertiesChanged, onScrollChanged, onSizeChanged, onStartTemporaryDetach, onTouchEvent, onVisibilityAggregated, onVisibilityChanged, onWindowFocusChanged, onWindowVisibilityChanged, overScrollBy, performButtonActionOnTouchDown, performClick, performContextClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, performLongClick, playSoundEffect, pointInView, post, postDelayed, postInvalidate, postInvalidateDelayed, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestFocus, requestFocus, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, requireViewById, resetPivot, resolveSize, resolveSizeAndState, scheduleDrawable, scrollBy, scrollTo, setActivated, setAlpha, setAnimationMatrix, setBackground, setBottom, setClickable, setContextClickable, setDuplicateParentStateEnabled, setElevation, setEnabled, setFocusable, setFocusable, setFocusableInTouchMode, setFocusedByDefault, setFocusedInCluster, setForeground, setForegroundGravity, setFrame, setHapticFeedbackEnabled, setHasTransientState, setHasTranslationTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHorizontalScrollbarThumbDrawable, setHorizontalScrollbarTrackDrawable, setHovered, setId, setIsRootNamespace, setKeyboardNavigationCluster, setLayoutDirection, setLayoutParams, setLeft, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextClusterForwardId, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnTouchListener, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPressed, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setScaleX, setScaleY, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setStateListAnimator, setTag, setTextAlignment, setTextDirection, setTooltipText, setTop, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarThumbDrawable, setVerticalScrollbarTrackDrawable, setVisibility, setWillNotDraw, setX, setY, setZ, showContextMenu, showContextMenu, sp, startActionMode, startActionMode, startDragAndDrop, startNestedScroll, stopNestedScroll, toGlobalMotionEvent, toLocalMotionEvent, toString, transformFromViewToWindowSpace, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, unscheduleDrawable, verifyDrawable, willNotDraw
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface icyllis.modernui.view.ViewParent
canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, createContextMenu, getLayoutDirection, getParent, getTextAlignment, getTextDirection, isLayoutDirectionResolved, isLayoutRequested, isTextAlignmentResolved, isTextDirectionResolved, keyboardNavigationClusterSearch, requestLayout
-
Field Details
-
FOCUS_BEFORE_DESCENDANTS
public static final int FOCUS_BEFORE_DESCENDANTSThis view will get focus before any of its descendants.- See Also:
-
FOCUS_AFTER_DESCENDANTS
public static final int FOCUS_AFTER_DESCENDANTSThis view will get focus only if none of its descendants want it.- See Also:
-
FOCUS_BLOCK_DESCENDANTS
public static final int FOCUS_BLOCK_DESCENDANTSThis view will block any of its descendants from getting focus, even if they are focusable.- See Also:
-
FLAG_DISALLOW_INTERCEPT
@Internal protected static final int FLAG_DISALLOW_INTERCEPTWhen set, this ViewGroup should not intercept touch events.- See Also:
-
CLIP_TO_PADDING_MASK
protected static final int CLIP_TO_PADDING_MASKWe clip to padding when FLAG_CLIP_TO_PADDING and FLAG_PADDING_NOT_NULL are set at the same time.- See Also:
-
-
Constructor Details
-
ViewGroup
-
-
Method Details
-
dispatchDraw
Description copied from class:View
Draw the child views.- Overrides:
dispatchDraw
in classView
- Parameters:
canvas
- the canvas to draw content
-
drawChild
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
- The canvas on which to draw the childchild
- Who to drawdrawingTime
- The time at which draw is occurring
-
layout
public final void layout(int l, int t, int r, int b) Description copied from class:View
Specifies the rectangle area of this view and all its descendants.Derived classes should NOT override this method for any reason. Derived classes with children should override
View.onLayout(boolean, int, int, int, int)
. In that method, they should call layout() on each of their children. -
onLayout
protected abstract void onLayout(boolean changed, int left, int top, int right, int bottom) Description copied from class:View
Called fromView.layout(int, int, int, int)
when this view should assign a size and position to each of its children.Derived classes with children should override this method and call layout on each of their children.
-
dispatchHoverEvent
Description copied from class:View
Dispatch a hover event.Do not call this method directly. Call
View.dispatchGenericMotionEvent(MotionEvent)
instead.- Overrides:
dispatchHoverEvent
in classView
- Parameters:
event
- The motion event to be dispatched.- Returns:
- True if the event was handled by the view, false otherwise.
-
onInterceptHoverEvent
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
View.onHoverEvent(icyllis.modernui.view.MotionEvent)
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 returntrue
from this method 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 inView.onHoverEvent(icyllis.modernui.view.MotionEvent)
. Likewise, if this method had previously returnedtrue
to intercept hover events and instead returnsfalse
while the pointer is hovering within the bounds of one of a child, then the view group will first receive a hover exit event inView.onHoverEvent(icyllis.modernui.view.MotionEvent)
and then the hovered child will receive a hover enter event.The default implementation handles mouse hover on the scroll bars.
- Parameters:
event
- The motion event that describes the hover.- Returns:
- True if the view group would like to intercept the hover event and prevent its children from receiving it.
-
dispatchGenericPointerEvent
Description copied from class:View
Dispatch a generic motion event to the view under the first pointer.Do not call this method directly. Call
View.dispatchGenericMotionEvent(MotionEvent)
instead.- Overrides:
dispatchGenericPointerEvent
in classView
- Parameters:
event
- The motion event to be dispatched.- Returns:
- True if the event was handled by the view, false otherwise.
-
dispatchTouchEvent
Description copied from class:View
Pass the touch screen motion event down to the target view, or this view if it is the target.- Overrides:
dispatchTouchEvent
in classView
- Parameters:
ev
- The motion event to be dispatched.- Returns:
true
if the event was handled by the view,false
otherwise
-
isTransitionGroup
public boolean isTransitionGroup()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.- Returns:
- 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
View.getTransitionName()
is not null and false otherwise.
-
setTransitionGroup
public void setTransitionGroup(boolean isTransitionGroup) Changes whether or not this ViewGroup should be treated as a single entity during Activity Transitions.- Parameters:
isTransitionGroup
- 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.
-
requestDisallowInterceptTouchEvent
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) Description copied from interface:ViewParent
Called when a child does not want this parent and its ancestors to intercept touch events withonInterceptTouchEvent(MotionEvent)
.This parent should pass this call onto its parents. This parent must obey this request for the duration of the touch (that is, only clear the flag after this parent has received an up or a cancel.
- Specified by:
requestDisallowInterceptTouchEvent
in interfaceViewParent
- Parameters:
disallowIntercept
- True if the child does not want the parent to intercept touch events.
-
onInterceptTouchEvent
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
- The motion event being dispatched down the hierarchy.- Returns:
- 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.
-
requestFocus
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 (
View.isFocusable()
returns false), or if it is focusable and it is not focusable in touch mode (View.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
getDescendantFocusability()
equal toFOCUS_BLOCK_DESCENDANTS
.See also
View.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 internalView
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, Rect)
to find focus within the children of this group when appropriate.- Overrides:
requestFocus
in classView
- Parameters:
direction
- One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHTpreviouslyFocusedRect
- 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.- Returns:
- Whether this view or one of its descendants actually took focus.
- See Also:
-
onRequestFocusInDescendants
Look for a descendant to callView.requestFocus()
on. Called byrequestFocus(int, Rect)
when it wants to request focus within its children. Override this to customize how yourViewGroup
requests focus within its children.- Parameters:
direction
- One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHTpreviouslyFocusedRect
- 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.- Returns:
- Whether focus was taken.
-
restoreDefaultFocus
public boolean restoreDefaultFocus()Description copied from class:View
Gives focus to the default-focus view in the view hierarchy that has this view as a root. If the default-focus view cannot be found, falls back to callingView.requestFocus(int)
.- Overrides:
restoreDefaultFocus
in classView
- Returns:
- Whether this view or one of its descendants actually took focus
-
dispatchStartTemporaryDetach
@Internal public void dispatchStartTemporaryDetach()DispatchView.onStartTemporaryDetach()
to this View and its direct children if this is a container View.- Overrides:
dispatchStartTemporaryDetach
in classView
-
dispatchFinishTemporaryDetach
@Internal public void dispatchFinishTemporaryDetach()DispatchView.onFinishTemporaryDetach()
to this View and its direct children if this is a container View.- Overrides:
dispatchFinishTemporaryDetach
in classView
-
transformPointToViewLocal
-
dispatchKeyEvent
Description copied from class:View
Dispatch a key event to the next view on the focus path. This path runs from the top of the view tree down to the currently focused view. If this view has focus, it will dispatch to itself. Otherwise it will dispatch the next node down the focus path. This method also fires any key listeners.- Overrides:
dispatchKeyEvent
in classView
- Parameters:
event
- The key event to be dispatched.- Returns:
- True if the event was handled, false otherwise.
-
dispatchKeyShortcutEvent
Description copied from class:View
Dispatches a key shortcut event.- Overrides:
dispatchKeyShortcutEvent
in classView
- Parameters:
event
- The key event to be dispatched.- Returns:
- True if the event was handled by the view, false otherwise.
-
onResolvePointerIcon
Description copied from class:View
Returns the pointer icon for the motion event, or null if it doesn't specify the icon. The default implementation does not care the location or event types, but some subclasses may use it (such as WebViews).- Overrides:
onResolvePointerIcon
in classView
- Parameters:
event
- The MotionEvent from a mouse- See Also:
-
addTransientView
This method adds a view to this container at the specified index purely for the purposes of allowing that view to draw even though it is not a normal child of the container. That is, the view does not participate in layout, focus, accessibility, input, or other normal view operations; it is purely an item to be drawn during the normal rendering operation of this container. The index that it is added at is the order in which it will be drawn, with respect to the other views in the container. For example, a transient view added at index 0 will be drawn before all other views in the container because it will be drawn first (including before any real view at index 0). There can be more than one transient view at any particular index; these views will be drawn in the order in which they were added to the list of transient views. The index of transient views can also be greater than the number of normal views in the container; that just means that they will be drawn after all other views are drawn.Note that since transient views do not participate in layout, they must be sized manually or, more typically, they should just use the size that they had before they were removed from their container.
Transient views are useful for handling animations of views that have been removed from the container, but which should be animated out after the removal. Adding these views as transient views allows them to participate in drawing without side-effecting the layout of the container.
Transient views must always be explicitly
removed
from the container when they are no longer needed. For example, a transient view which is added in order to fade it out in its old location should be removed once the animation is complete.- Parameters:
view
- The view to be added. The view must not have a parent.index
- The index at which this view should be drawn, must be >= 0. This value is relative to theindex
values in the normal child list of this container, where any transient view at a particular index will be drawn before any normal child at that same index.
-
removeTransientView
Removes a view from the list of transient views in this container. If there is no such transient view, this method does nothing.- Parameters:
view
- The transient view to be removed
-
getTransientViewCount
@Internal public int getTransientViewCount()Returns the number of transient views in this container. Specific transient views and the index at which they were added can be retrieved viagetTransientView(int)
andgetTransientViewIndex(int)
.- Returns:
- The number of transient views in this container
- See Also:
-
getTransientViewIndex
@Internal public int getTransientViewIndex(int position) Given a valid position within the list of transient views, returns the index of the transient view at that position.- Parameters:
position
- The position of the index being queried. Must be at least 0 and less than the value returned bygetTransientViewCount()
.- Returns:
- The index of the transient view stored in the given position if the position is valid, otherwise -1
-
getTransientView
Given a valid position within the list of transient views, returns the transient view at that position.- Parameters:
position
- The position of the view being queried. Must be at least 0 and less than the value returned bygetTransientViewCount()
.- Returns:
- The transient view stored in the given position if the position is valid, otherwise null
-
addView
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
View.draw(Canvas)
,View.onDraw(Canvas)
,dispatchDraw(Canvas)
or any related method.- Parameters:
child
- the child view to add- See Also:
-
addView
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
View.draw(Canvas)
,View.onDraw(Canvas)
,dispatchDraw(Canvas)
or any related method.- Parameters:
child
- the child view to addindex
- the position at which to add the child- See Also:
-
addView
Adds a child view with this ViewGroup's default layout parameters and the specified width and height.Note: do not invoke this method from
View.draw(Canvas)
,View.onDraw(Canvas)
,dispatchDraw(Canvas)
or any related method.- Parameters:
child
- the child view to add
-
addView
Adds a child view with the specified layout parameters.Note: do not invoke this method from
View.draw(Canvas)
,View.onDraw(Canvas)
,dispatchDraw(Canvas)
or any related method.- Specified by:
addView
in interfaceViewManager
- Parameters:
child
- the child view to addparams
- the layout parameters to set on the child
-
addView
Adds a child view with the specified layout parameters.Note: do not invoke this method from
View.draw(Canvas)
,View.onDraw(Canvas)
,dispatchDraw(Canvas)
or any related method.- Parameters:
child
- the child view to addindex
- the position at which to add the child or -1 to add lastparams
- the layout parameters to set on the child
-
updateViewLayout
- Specified by:
updateViewLayout
in interfaceViewManager
-
addViewInLayout
protected boolean addViewInLayout(@NonNull View child, int index, @NonNull ViewGroup.LayoutParams params) 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
- the view to add to the groupindex
- the index at which the child must be added or -1 to add lastparams
- the layout parameters to associate with the child- Returns:
- true if the child was added, false otherwise
-
addViewInLayout
protected boolean addViewInLayout(@NonNull View child, int index, @NonNull ViewGroup.LayoutParams params, boolean preventRequestLayout) 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
- the view to add to the groupindex
- the index at which the child must be added or -1 to add lastparams
- the layout parameters to associate with the childpreventRequestLayout
- if true, calling this method will not trigger a layout request on child- Returns:
- true if the child was added, false otherwise
-
cleanupLayoutState
Prevents the specified child to be laid out during the next layout pass.- Parameters:
child
- the child on which to perform the cleanup
-
onViewAdded
Called when a new child is added to this ViewGroup. Overrides should always call super.onViewAdded.- Parameters:
child
- the added child view
-
onViewRemoved
Called when a child view is removed from this ViewGroup. Overrides should always call super.onViewRemoved.- Parameters:
child
- the removed child view
-
indexOfChild
Returns the position in the group of the specified child view.- Parameters:
child
- the view for which to get the position- Returns:
- a positive integer representing the position of the view in the group, or -1 if the view does not exist in the group
-
getChildAt
Returns the view at the specified position in the group.- Parameters:
index
- the position at which to get the view from- Returns:
- the view at the specified position or null if the position does not exist within the group
-
getChildCount
public int getChildCount()Returns the number of children in the group.- Returns:
- a positive integer representing the number of children in the group
-
removeView
Note: do not invoke this method from
View.draw(Canvas)
,View.onDraw(Canvas)
,dispatchDraw(Canvas)
or any related method.- Specified by:
removeView
in interfaceViewManager
-
removeViewInLayout
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
View.draw(Canvas)
,View.onDraw(Canvas)
,dispatchDraw(Canvas)
or any related method.- Parameters:
view
- the view to remove from the group
-
removeViewsInLayout
public void removeViewsInLayout(int start, int count) 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
View.draw(Canvas)
,View.onDraw(Canvas)
,dispatchDraw(Canvas)
or any related method.- Parameters:
start
- the index of the first view to remove from the groupcount
- the number of views to remove from the group
-
removeViewAt
public void removeViewAt(int index) Removes the view at the specified position in the group.Note: do not invoke this method from
View.draw(Canvas)
,View.onDraw(Canvas)
,dispatchDraw(Canvas)
or any related method.- Parameters:
index
- the position in the group of the view to remove
-
removeViews
public void removeViews(int start, int count) Removes the specified range of views from the group.Note: do not invoke this method from
View.draw(Canvas)
,View.onDraw(Canvas)
,dispatchDraw(Canvas)
or any related method.- Parameters:
start
- the first position in the group of the range of views to removecount
- the number of views to remove
-
setLayoutTransition
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
- The LayoutTransition object that will animated changes in layout. A value ofnull
means no transition will run on layout changes.
-
getLayoutTransition
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).- Returns:
- LayoutTranstion The LayoutTransition object that will animated changes in layout.
A value of
null
means no transition will run on layout changes.
-
removeAllViews
public void removeAllViews()Call this method to remove all child views from the ViewGroup.Note: do not invoke this method from
View.draw(Canvas)
,View.onDraw(icyllis.modernui.graphics.Canvas)
,View.dispatchDraw(Canvas)
or any related method. -
removeAllViewsInLayout
public void removeAllViewsInLayout()Called by a ViewGroup subclass to remove child views from itself, when it must first know its size on screen before it can calculate how many child views it will render. 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
View.draw(Canvas)
,View.onDraw(icyllis.modernui.graphics.Canvas)
,View.dispatchDraw(Canvas)
or any related method. -
removeDetachedView
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
View.requestLayout()
orView.invalidate()
calls. For example, callers canpost
aRunnable
which performs aView.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
- the child to be definitely removed from the view hierarchyanimate
- if true and the view has an animation, the view is placed in the disappearing views list, otherwise, it is detached from the window- See Also:
-
attachViewToParent
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 callinggetChildAt(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
View.requestLayout()
orView.invalidate()
calls. For example, callers canpost
aRunnable
which performs aView.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
- the child to attachindex
- the index at which the child should be attachedparams
- the layout parameters of the child- See Also:
-
detachViewFromParent
Detaches a view from its parent. Detaching a view should be followed either by a call toattachViewToParent(View, int, ViewGroup.LayoutParams)
or a call toremoveDetachedView(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 togetChildAt(int)
.- Parameters:
child
- the child to detach- See Also:
-
detachViewFromParent
protected void detachViewFromParent(int index) Detaches a view from its parent. Detaching a view should be followed either by a call toattachViewToParent(View, int, ViewGroup.LayoutParams)
or a call toremoveDetachedView(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 togetChildAt(int)
.- Parameters:
index
- the index of the child to detach- See Also:
-
detachViewsFromParent
protected void detachViewsFromParent(int start, int count) Detaches a range of views from their parents. Detaching a view should be followed either by a call toattachViewToParent(View, int, ViewGroup.LayoutParams)
or a call toremoveDetachedView(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 togetChildAt(int)
.- Parameters:
start
- the first index of the childrend range to detachcount
- the number of children to detach- See Also:
-
detachAllViewsFromParent
protected void detachAllViewsFromParent()Detaches all views from the parent. Detaching a view should be followed either by a call toattachViewToParent(View, int, ViewGroup.LayoutParams)
or a call toremoveDetachedView(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 togetChildAt(int)
.- See Also:
-
getDescendantFocusability
public int getDescendantFocusability()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 inView.requestFocus(int)
.- Returns:
- one of
FOCUS_BEFORE_DESCENDANTS
,FOCUS_AFTER_DESCENDANTS
,FOCUS_BLOCK_DESCENDANTS
.
-
setDescendantFocusability
public void setDescendantFocusability(int focusability) 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 inView.requestFocus(int)
.- Parameters:
focusability
- one ofFOCUS_BEFORE_DESCENDANTS
,FOCUS_AFTER_DESCENDANTS
,FOCUS_BLOCK_DESCENDANTS
.
-
requestChildFocus
Description copied from interface:ViewParent
Called when a child of this parent wants focus- Specified by:
requestChildFocus
in interfaceViewParent
- Parameters:
child
- 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
- The view that is a descendant of child that actually has focus
-
dispatchWindowFocusChanged
public void dispatchWindowFocusChanged(boolean hasFocus) Description copied from class:View
Called when the window containing this view gains or loses window focus. ViewGroups should override to route to their children.- Overrides:
dispatchWindowFocusChanged
in classView
- Parameters:
hasFocus
- True if the window containing this view now has focus, false otherwise.
-
addFocusables
Description copied from class:View
Adds any focusable views that are descendants of this view (possibly including this view if it is focusable itself) to views. This method adds all focusable views regardless if we are in touch mode or only views focusable in touch mode if we are in touch mode or only views that can take accessibility focus if accessibility is enabled depending on the focusable mode parameter.- Overrides:
addFocusables
in classView
- Parameters:
views
- Focusable views found so far or null if all we are interested is the number of focusables.direction
- The direction of the focus.
-
addTouchables
Description copied from class:View
Add any touchable views that are descendants of this view (possibly including this view if it is touchable itself) to views.- Overrides:
addTouchables
in classView
- Parameters:
views
- Touchable views found so far
-
setTouchscreenBlocksFocus
public void setTouchscreenBlocksFocus(boolean touchscreenBlocksFocus) 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
- true to enable blocking focus in the presence of a touchscreen
-
getTouchscreenBlocksFocus
public boolean getTouchscreenBlocksFocus()Check whether this ViewGroup should ignore focus requests for itself and its children. -
childHasTransientStateChanged
Called when a child view has changed whether it is tracking transient state.- Specified by:
childHasTransientStateChanged
in interfaceViewParent
- Parameters:
child
- Child view whose state has changedchildHasTransientState
- true if this child has transient state
-
hasTransientState
public boolean hasTransientState()Description copied from class:View
Indicates whether the view is currently tracking transient state that the app should not need to concern itself with saving and restoring, but that the framework should take special note to preserve when possible.A view with transient state cannot be trivially rebound from an external data source, such as an adapter binding item views in a list. This may be because the view is performing an animation, tracking user selection of content, or similar.
- Overrides:
hasTransientState
in classView
- Returns:
- true if the view has transient state
-
clearChildFocus
Description copied from interface:ViewParent
Called when a child of this parent is giving up focus- Specified by:
clearChildFocus
in interfaceViewParent
- Parameters:
child
- The view that is giving up focus
-
clearFocus
public void clearFocus()Description copied from class:View
Called when this view wants to give up focus. If focus is clearedView.onFocusChanged(boolean, int, Rect)
is called.Note: When not in touch-mode, the framework will try to give focus to the first focusable View from the top after focus is cleared. Hence, if this View is the first from the top that can take focus, then all callbacks related to clearing focus will be invoked after which the framework will give focus to this view.
- Overrides:
clearFocus
in classView
-
getFocusedChild
Returns the focused child of this view, if any. The child may have focus or contain focus.- Returns:
- the focused child or null.
-
hasFocus
public boolean hasFocus()Returns true if this view has or contains focus -
findFocus
Description copied from class:View
Find the view in the hierarchy rooted at this view that currently has focus. -
offsetDescendantRectToMyCoords
Offset a rectangle that is in a descendant's coordinate space into our coordinate space.- Parameters:
descendant
- A descendant of this viewrect
- A rectangle defined in descendant's coordinate space.
-
offsetRectIntoDescendantCoords
Offset a rectangle that is in our coordinate space into an ancestor's coordinate space.- Parameters:
descendant
- A descendant of this viewrect
- A rectangle defined in descendant's coordinate space.
-
offsetChildrenTopAndBottom
public void offsetChildrenTopAndBottom(int offset) Offset the vertical location of all children of this view by the specified number of pixels.- Parameters:
offset
- the number of pixels to offset
-
getChildVisibleRect
Description copied from interface:ViewParent
Compute the visible part of a rectangular region defined in terms of a child view's coordinates.Returns the clipped visible part of the rectangle
r
, defined in thechild
's local coordinate system.r
is modified by this method to contain the result, expressed in the global (root) coordinate system.The resulting rectangle is always axis aligned. If a rotation is applied to a node in the View hierarchy, the result is the axis-aligned bounding box of the visible rectangle.
- Specified by:
getChildVisibleRect
in interfaceViewParent
- Parameters:
child
- A child View, whose rectangular visible region we want to computer
- The input rectangle, defined in the child coordinate system. Will be overwritten to contain the resulting visible rectangle, expressed in global (root) coordinatesoffset
- The input coordinates of a point, defined in the child coordinate system. As with ther
parameter, this will be overwritten to contain the global (root) coordinates of that point. Anull
value is valid (in case you are not interested in this result)- Returns:
- true if the resulting rectangle is not empty, false otherwise
-
getChildVisibleRect
@Internal public boolean getChildVisibleRect(@NonNull View child, Rect r, @Nullable Point offset, boolean forceParentCheck) - Parameters:
forceParentCheck
- true to guarantee that this call will propagate to all ancestors, false otherwise
-
focusSearch
Find the nearest view in the specified direction that wants to take focus.- Specified by:
focusSearch
in interfaceViewParent
- Parameters:
focused
- The view that currently has focusdirection
- One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT, or 0 for not applicable.
-
requestChildRectangleOnScreen
Description copied from interface:ViewParent
Called when a child of this group wants a particular rectangle to be positioned onto the screen.ViewGroup
s overriding this can trust that:- child will be a direct child of this group
- rectangle will be in the child's content coordinates
ViewGroup
s overriding this should uphold the contract:- nothing will change if the rectangle is already visible
- the view port will be scrolled only just enough to make the rectangle visible
- Specified by:
requestChildRectangleOnScreen
in interfaceViewParent
- Parameters:
child
- The direct child making the request.rectangle
- The rectangle in the child's coordinates the child wishes to be on the screen.immediate
- True to forbid animated or delayed scrolling, false otherwise- Returns:
- Whether the group scrolled to handle the operation
-
focusableViewAvailable
Description copied from interface:ViewParent
Tells the parent that a new focusable view has become available. This is to handle transitions from the case where there are no focusable views to the case where the first focusable view appears.- Specified by:
focusableViewAvailable
in interfaceViewParent
- Parameters:
v
- The view that has become newly focusable
-
showContextMenuForChild
Description copied from interface:ViewParent
Shows the context menu for the specified view or its ancestors anchored to the specified view-relative coordinate.In most cases, a subclass does not need to override this. However, if the subclass is added directly to the window manager (for example,
ViewManager.addView(View, ViewGroup.LayoutParams)
) then it should override this and show the context menu.- Specified by:
showContextMenuForChild
in interfaceViewParent
- Parameters:
originalView
- the source view where the context menu was first invokedx
- the X coordinate in pixels relative to the original view to which the menu should be anchored, orFloat.NaN
to disable anchoringy
- the Y coordinate in pixels relative to the original view to which the menu should be anchored, orFloat.NaN
to disable anchoring- Returns:
true
if the context menu was shown,false
otherwise
-
startActionModeForChild
public ActionMode startActionModeForChild(View originalView, ActionMode.Callback callback, int type) Description copied from interface:ViewParent
Start an action mode of a specific type for the specified view.In most cases, a subclass does not need to override this. However, if the subclass is added directly to the window manager (for example,
ViewManager.addView(View, ViewGroup.LayoutParams)
) then it should override this and start the action mode.- Specified by:
startActionModeForChild
in interfaceViewParent
- Parameters:
originalView
- The source view where the action mode was first invokedcallback
- The callback that will handle lifecycle events for the action modetype
- One ofActionMode.TYPE_PRIMARY
orActionMode.TYPE_FLOATING
.- Returns:
- The new action mode if it was started, null otherwise
-
setClipToPadding
public void setClipToPadding(boolean clipToPadding) Sets whether this ViewGroup will clip its children to its padding and resize (but not clip) any EdgeEffect to the padded region, if padding is present.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
- true to clip children to the padding of the group, and resize (but not clip) any EdgeEffect to the padded region. False otherwise.
-
getClipToPadding
public boolean getClipToPadding()Returns whether this ViewGroup will clip its children to its padding, and resize (but not clip) any EdgeEffect to the padded region, if padding is present.By default, children are clipped to the padding of their parent Viewgroup. This clipping behavior is only enabled if padding is non-zero.
- Returns:
- true if this ViewGroup clips children to its padding and resizes (but doesn't clip) any EdgeEffect to the padded region, false otherwise.
-
dispatchSetSelected
public void dispatchSetSelected(boolean selected) Description copied from class:View
Dispatch setSelected to all of this View's children.- Overrides:
dispatchSetSelected
in classView
- Parameters:
selected
- The new selected state- See Also:
-
dispatchSetActivated
public void dispatchSetActivated(boolean activated) Description copied from class:View
Dispatch setActivated to all of this View's children.- Overrides:
dispatchSetActivated
in classView
- Parameters:
activated
- The new activated state- See Also:
-
dispatchSetPressed
protected void dispatchSetPressed(boolean pressed) Description copied from class:View
Dispatch setPressed to all of this View's children.- Overrides:
dispatchSetPressed
in classView
- Parameters:
pressed
- The new pressed state- See Also:
-
dispatchDrawableHotspotChanged
public void dispatchDrawableHotspotChanged(float x, float y) Dispatches drawable hotspot changes to child views that meet at least one of the following criteria:- Returns
false
from bothView.isClickable()
andView.isLongClickable()
- Requests duplication of parent state via
View.setDuplicateParentStateEnabled(boolean)
- Overrides:
dispatchDrawableHotspotChanged
in classView
- Parameters:
x
- hotspot x coordinatey
- hotspot y coordinate- See Also:
- Returns
-
findViewByPredicateTraversal
@Nullable protected <T extends View> T findViewByPredicateTraversal(@NonNull Predicate<View> predicate, @Nullable View childToSkip) - Overrides:
findViewByPredicateTraversal
in classView
- Parameters:
predicate
- The predicate to evaluate.childToSkip
- If not null, ignores this child during the recursive traversal.- Returns:
- The first view that matches the predicate or null.
-
findViewTraversal
- Overrides:
findViewTraversal
in classView
- Parameters:
id
- the id of the view to be found- Returns:
- the view of the specified id, null if cannot be found
-
bringChildToFront
Description copied from interface:ViewParent
Change the z order of the child, so it's on top of all other children. This ordering change may affect layout, if this container uses an order-dependent layout scheme (e.g., LinearLayout).- Specified by:
bringChildToFront
in interfaceViewParent
- Parameters:
child
- The child to bring to the top of the z order
-
hasBooleanFlag
protected boolean hasBooleanFlag(int flag) -
setBooleanFlag
protected void setBooleanFlag(int flag, boolean value) -
isChildrenDrawingOrderEnabled
protected boolean isChildrenDrawingOrderEnabled()Indicates whether the ViewGroup is drawing its children in the order defined bygetChildDrawingOrder(int, int)
.- Returns:
- true if children drawing order is defined by
getChildDrawingOrder(int, int)
, false otherwise - See Also:
-
setChildrenDrawingOrderEnabled
protected void setChildrenDrawingOrderEnabled(boolean enabled) Tells the ViewGroup whether to draw its children in the order defined by the methodgetChildDrawingOrder(int, int)
.Note that View#getZ() reordering, done by
View.dispatchDraw(Canvas)
, will override custom child ordering done via this method.- Parameters:
enabled
- true if the order of the children when drawing is determined bygetChildDrawingOrder(int, int)
, false otherwise- See Also:
-
getChildDrawingOrder
protected int getChildDrawingOrder(int childCount, int drawingPosition) 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
- the drawing order position.- Returns:
- the container position of a child for this drawing order position.
- See Also:
-
getChildDrawingOrder
public final int getChildDrawingOrder(int drawingPosition) 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
- the drawing order position.- Returns:
- the container position of a child for this drawing order position.
- See Also:
-
drawableStateChanged
protected void drawableStateChanged()Description copied from class:View
This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.If the View has a StateListAnimator, it will also be called to run necessary state change animations.
Be sure to call through to the superclass when overriding this function.
- Overrides:
drawableStateChanged
in classView
- See Also:
-
jumpDrawablesToCurrentState
public void jumpDrawablesToCurrentState()Description copied from class:View
CallDrawable.jumpToCurrentState()
on all Drawable objects associated with this view.Also calls
StateListAnimator.jumpToCurrentState()
if there is a StateListAnimator attached to this view.- Overrides:
jumpDrawablesToCurrentState
in classView
-
onCreateDrawableState
Description copied from class:View
Generate the newDrawable
state for this view. This is called by the view system when the cached Drawable state is determined to be invalid. To retrieve the current state, you should useView.getDrawableState()
.- Overrides:
onCreateDrawableState
in classView
- Parameters:
extraSpace
- 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.- Returns:
- an array holding the current
Drawable
state of the view. - See Also:
-
setAddStatesFromChildren
public void setAddStatesFromChildren(boolean addsStates) 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. -
addStatesFromChildren
public boolean addStatesFromChildren()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. -
childDrawableStateChanged
IfaddStatesFromChildren()
is true, refreshes this group's drawable state (to include the states from its children).- Specified by:
childDrawableStateChanged
in interfaceViewParent
- Parameters:
child
- The child whose drawable state has changed.
-
requestTransitionStart
This method is called by LayoutTransition when there are 'changing' animations that need to start after the layout/setup phase. The request is forwarded to the ViewAncestor, who starts all pending transitions prior to the drawing phase in the current traversal.- Parameters:
transition
- The LayoutTransition to be started on the next traversal.
-
resolveRtlPropertiesIfNeeded
@Internal public boolean resolveRtlPropertiesIfNeeded()Description copied from class:View
Resolve all RTL related properties.- Overrides:
resolveRtlPropertiesIfNeeded
in classView
- Returns:
- true if resolution of RTL properties has been done
-
resolveLayoutDirection
@Internal public boolean resolveLayoutDirection()Description copied from class:View
Resolve and cache the layout direction. LTR is set initially. This is implicitly supposing that the parent directionality can and will be resolved before its children.- Overrides:
resolveLayoutDirection
in classView
- Returns:
- true if resolution has been done, false otherwise.
-
resolveTextDirection
@Internal public boolean resolveTextDirection()Description copied from class:View
Resolve the text direction.- Overrides:
resolveTextDirection
in classView
- Returns:
- true if resolution has been done, false otherwise.
-
resolveTextAlignment
@Internal public boolean resolveTextAlignment()Description copied from class:View
Resolve the text alignment.- Overrides:
resolveTextAlignment
in classView
- Returns:
- true if resolution has been done, false otherwise.
-
resolvePadding
@Internal public void resolvePadding()Description copied from class:View
Resolves padding depending on layout direction, if applicable, and recomputes internal padding values to adjust for scroll bars.- Overrides:
resolvePadding
in classView
-
resolveDrawables
@Internal protected void resolveDrawables()Description copied from class:View
Resolve the Drawables depending on the layout direction. This is implicitly supposing that the View directionality can and will be resolved before its Drawables.Will call
View.onResolveDrawables(int)
when resolution is done.- Overrides:
resolveDrawables
in classView
-
resolveLayoutParams
@Internal public void resolveLayoutParams()Description copied from class:View
Resolve the layout parameters depending on the resolved layout direction- Overrides:
resolveLayoutParams
in classView
-
resetResolvedDrawables
@Internal protected void resetResolvedDrawables()- Overrides:
resetResolvedDrawables
in classView
-
getClipChildren
public boolean getClipChildren()Returns whether this group's children are clipped to their bounds before drawing. The default value is true.- Returns:
- True if the group's children will be clipped to their bounds, false otherwise.
- See Also:
-
setClipChildren
public void setClipChildren(boolean clipChildren) By default, children are clipped to their bounds before drawing. This allows view groups to override this behavior for animations, etc.- Parameters:
clipChildren
- true to clip children to their bounds, false otherwise
-
measureChildren
protected void measureChildren(int widthMeasureSpec, int heightMeasureSpec) Ask all 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
- The width requirements for this viewheightMeasureSpec
- The height requirements for this view
-
measureChild
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
- The child to measureparentWidthSpec
- The width requirements for this viewparentHeightSpec
- The height requirements for this view
-
measureChildWithMargins
protected void measureChildWithMargins(@NonNull View child, int parentWidthSpec, int widthUsed, int parentHeightSpec, int heightUsed) Ask one of the children of this view to measure itself, taking into account both the MeasureSpec requirements for this view and its padding and margins. The child must have MarginLayoutParams The heavy lifting is done in getChildMeasureSpec.- Parameters:
child
- The child to measureparentWidthSpec
- The width requirements for this viewwidthUsed
- Extra space that has been used up by the parent horizontally (possibly by other children of the parent)parentHeightSpec
- The height requirements for this viewheightUsed
- Extra space that has been used up by the parent vertically (possibly by other children of the parent)
-
getChildMeasureSpec
public static int getChildMeasureSpec(int spec, int padding, int childDimension) Does the hard part of measureChildren: figuring out the MeasureSpec to pass to a particular child. 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
- The requirements for this viewpadding
- The padding of this view for the current dimension and margins, if applicablechildDimension
- How big the child wants to be in the current dimension- Returns:
- a MeasureSpec integer for the child
-
clearDisappearingChildren
public void clearDisappearingChildren()Removes any pending animations for views that have been removed. Call this if you don't want animations for exiting views to stack up. -
startViewTransition
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 byFragment
andLayoutTransition
to animate the removal of views. A call to this method should always be accompanied by a later call toendViewTransition(View)
, such as after an animation on the View has finished, so that the View finally gets removed.- Parameters:
view
- The View object to be kept visible even if it gets removed from its parent.
-
endViewTransition
This method should always be called following an earlier call tostartViewTransition(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.- Parameters:
view
- The View object that has been removed but is being kept around in the visible hierarchy by an earlier call tostartViewTransition(View)
.
-
suppressLayout
public void suppressLayout(boolean suppress) 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. -
isLayoutSuppressed
public boolean isLayoutSuppressed()Returns whether layout calls on this container are currently being suppressed, due to an earlier call tosuppressLayout(boolean)
.- Returns:
- true if layout calls are currently suppressed, false otherwise.
-
internalSetPadding
@Internal protected void internalSetPadding(int left, int top, int right, int bottom) - Overrides:
internalSetPadding
in classView
-
onChildVisibilityChanged
Called when a view's visibility has changed. Notify the parent to take any appropriate action.- Parameters:
child
- The view whose visibility has changedoldVisibility
- The previous visibility value (GONE, INVISIBLE, or VISIBLE).newVisibility
- The new visibility value (GONE, INVISIBLE, or VISIBLE).
-
dispatchVisibilityChanged
Description copied from class:View
Dispatch a view visibility change down the view hierarchy. ViewGroups should override to route to their children.- Overrides:
dispatchVisibilityChanged
in classView
- Parameters:
changedView
- The view whose visibility changed. Could be 'this' or an ancestor view.visibility
- The new visibility of changedView:View.VISIBLE
,View.INVISIBLE
orView.GONE
.
-
dispatchWindowVisibilityChanged
public void dispatchWindowVisibilityChanged(int visibility) Description copied from class:View
Dispatch a window visibility change down the view hierarchy. ViewGroups should override to route to their children.- Overrides:
dispatchWindowVisibilityChanged
in classView
- Parameters:
visibility
- The new visibility of the window.- See Also:
-
shouldDelayChildPressedState
public boolean shouldDelayChildPressedState()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.
-
onStartNestedScroll
Description copied from interface:ViewParent
React to a descendant view initiating a nestable scroll operation, claiming the nested scroll operation if appropriate.This method will be called in response to a descendant view invoking
View.startNestedScroll(int, int)
. Each parent up the view hierarchy will be given an opportunity to respond and claim the nested scrolling operation by returningtrue
.This method may be overridden by ViewParent implementations to indicate when the view is willing to support a nested scrolling operation that is about to begin. If it returns true, this ViewParent will become the target view's nested scrolling parent for the duration of the scroll operation in progress. When the nested scroll is finished this ViewParent will receive a call to
ViewParent.onStopNestedScroll(View, int)
.- Specified by:
onStartNestedScroll
in interfaceViewParent
- Parameters:
child
- Direct child of this ViewParent containing targettarget
- View that initiated the nested scrollaxes
- Flags consisting ofView.SCROLL_AXIS_HORIZONTAL
,View.SCROLL_AXIS_VERTICAL
or bothtype
- the type of input which cause this scroll event- Returns:
- true if this ViewParent accepts the nested scroll operation
-
onNestedScrollAccepted
Description copied from interface:ViewParent
React to the successful claiming of a nested scroll operation.This method will be called after
onStartNestedScroll
returns true. It offers an opportunity for the view and its superclasses to perform initial configuration for the nested scroll. Implementations of this method should always call their superclasses' implementation of this method if one is present.- Specified by:
onNestedScrollAccepted
in interfaceViewParent
- Parameters:
child
- Direct child of this ViewParent containing targettarget
- View that initiated the nested scrollaxes
- Flags consisting ofView.SCROLL_AXIS_HORIZONTAL
,View.SCROLL_AXIS_VERTICAL
or bothtype
- the type of input which cause this scroll event- See Also:
-
onStopNestedScroll
Description copied from interface:ViewParent
React to a nested scroll operation ending.Perform cleanup after a nested scrolling operation. This method will be called when a nested scroll stops, for example when a nested touch scroll ends with a
MotionEvent.ACTION_UP
orMotionEvent.ACTION_CANCEL
event. Implementations of this method should always call their superclasses' implementation of this method if one is present.- Specified by:
onStopNestedScroll
in interfaceViewParent
- Parameters:
target
- View that initiated the nested scrolltype
- the type of input which cause this scroll event
-
onNestedScroll
public void onNestedScroll(@NonNull View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type, @NonNull int[] consumed) Description copied from interface:ViewParent
React to a nested scroll in progress.This method will be called when the ViewParent's current nested scrolling child view dispatches a nested scroll event. To receive calls to this method the ViewParent must have previously returned
true
for a call toViewParent.onStartNestedScroll(View, View, int, int)
.Both the consumed and unconsumed portions of the scroll distance are reported to the ViewParent. An implementation may choose to use the consumed portion to match or chase scroll position of multiple child elements, for example. The unconsumed portion may be used to allow continuous dragging of multiple scrolling or draggable elements, such as scrolling a list within a vertical drawer where the drawer begins dragging once the edge of inner scrolling content is reached.
This method is called when a nested scrolling child invokes
View.dispatchNestedScroll(int, int, int, int, int[], int, int[])
} or one of methods it overloads.An implementation must report how many pixels of the x and y scroll distances were consumed by this nested scrolling parent by adding the consumed distances to the
consumed
parameter.consumed
should also be passed up to it's nested scrolling parent so that the parent may also add any scroll distance it consumes. Index 0 corresponds to dx and index 1 corresponds to dy.- Specified by:
onNestedScroll
in interfaceViewParent
- Parameters:
target
- The descendant view controlling the nested scrolldxConsumed
- Horizontal scroll distance in pixels already consumed by targetdyConsumed
- Vertical scroll distance in pixels already consumed by targetdxUnconsumed
- Horizontal scroll distance in pixels not consumed by targetdyUnconsumed
- Vertical scroll distance in pixels not consumed by targettype
- the type of input which cause this scroll eventconsumed
- Output. Upon this method returning, will contain the scroll distances consumed by this nested scrolling parent and the scroll distances consumed by any other parent up the view hierarchy- See Also:
-
onNestedPreScroll
public void onNestedPreScroll(@NonNull View target, int dx, int dy, @NonNull int[] consumed, int type) Description copied from interface:ViewParent
React to a nested scroll in progress before the target view consumes a portion of the scroll.When working with nested scrolling often the parent view may want an opportunity to consume the scroll before the nested scrolling child does. An example of this is a drawer that contains a scrollable list. The user will want to be able to scroll the list fully into view before the list itself begins scrolling.
onNestedPreScroll
is called when a nested scrolling child invokesView.dispatchNestedPreScroll(int, int, int[], int[], int)
. The implementation should report how any pixels of the scroll reported by dx, dy were consumed in theconsumed
array. Index 0 corresponds to dx and index 1 corresponds to dy. This parameter will never be null. Initial values for consumed[0] and consumed[1] will always be 0.- Specified by:
onNestedPreScroll
in interfaceViewParent
- Parameters:
target
- View that initiated the nested scrolldx
- Horizontal scroll distance in pixelsdy
- Vertical scroll distance in pixelsconsumed
- Output. The horizontal and vertical scroll distance consumed by this parenttype
- the type of input which cause this scroll event
-
onNestedFling
public boolean onNestedFling(@NonNull View target, float velocityX, float velocityY, boolean consumed) Description copied from interface:ViewParent
Request a fling from a nested scroll.This method signifies that a nested scrolling child has detected suitable conditions for a fling. Generally this means that a touch scroll has ended with a
velocity
in the direction of scrolling that meets or exceeds theminimum fling velocity
along a scrollable axis.If a nested scrolling child view would normally fling but it is at the edge of its own content, it can use this method to delegate the fling to its nested scrolling parent instead. The parent may optionally consume the fling or observe a child fling.
- Specified by:
onNestedFling
in interfaceViewParent
- Parameters:
target
- View that initiated the nested scrollvelocityX
- Horizontal velocity in pixels per secondvelocityY
- Vertical velocity in pixels per secondconsumed
- true if the child consumed the fling, false otherwise- Returns:
- true if this parent consumed or otherwise reacted to the fling
-
onNestedPreFling
Description copied from interface:ViewParent
React to a nested fling before the target view consumes it.This method signifies that a nested scrolling child has detected a fling with the given velocity along each axis. Generally this means that a touch scroll has ended with a
velocity
in the direction of scrolling that meets or exceeds theminimum fling velocity
along a scrollable axis.If a nested scrolling parent is consuming motion as part of a
pre-scroll
, it may be appropriate for it to also consume the pre-fling to complete that same motion. By returningtrue
from this method, the parent indicates that the child should not fling its own internal content as well.- Specified by:
onNestedPreFling
in interfaceViewParent
- Parameters:
target
- View that initiated the nested scrollvelocityX
- Horizontal velocity in pixels per secondvelocityY
- Vertical velocity in pixels per second- Returns:
- true if this parent consumed the fling ahead of the target view
-
getNestedScrollAxes
public int getNestedScrollAxes()Description copied from interface:ViewParent
Return the current axes of nested scrolling for this NestedScrollingParent.A NestedScrollingParent returning something other than
View.SCROLL_AXIS_NONE
is currently acting as a nested scrolling parent for one or more descendant views in the hierarchy.- Specified by:
getNestedScrollAxes
in interfaceViewParent
- Returns:
- Flags indicating the current axes of nested scrolling
- See Also:
-
onSetLayoutParams
-
generateLayoutParams
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 ofcheckLayoutParams(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
- The layout parameters to convert into a suitable set of layout parameters for this ViewGroup.- Returns:
- an instance of
ViewGroup.LayoutParams
or one of its descendants
-
generateDefaultLayoutParams
Returns a set of default layout parameters. These parameters are requested when the View passed toaddView(View)
has no layout parameters already set. If null is returned, an exception is thrown from addView.- Returns:
- a set of default layout parameters
-
checkLayoutParams
Check whether given params fit to this view group.See also
generateLayoutParams(LayoutParams)
See alsogenerateDefaultLayoutParams()
- Parameters:
p
- layout params to check- Returns:
- if params matched to this view group
-