public abstract class ViewGroup extends View implements ViewParent, ViewManager
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.
For more information about creating user interface layouts, read the XML Layouts developer guide.
Here is a complete implementation of a custom ViewGroup that implements
a simple FrameLayout
along with the ability to stack
children in left and right gutters.
If you are implementing XML layout attributes as shown in the example, this is the
corresponding definition for them that would go in res/values/attrs.xml
:
Finally the layout manager can be used in an XML layout like so:
Modifier and Type | Class and Description |
---|---|
static class |
ViewGroup.LayoutParams
LayoutParams are used by views to tell their parents how they want to be
laid out.
|
static class |
ViewGroup.MarginLayoutParams
Per-child layout information for layouts that support margins.
|
static interface |
ViewGroup.OnHierarchyChangeListener
Interface definition for a callback to be invoked when the hierarchy
within this view changed.
|
View.AccessibilityDelegate, View.BaseSavedState, View.DragShadowBuilder, View.DrawingCacheQuality, View.FindViewFlags, View.FocusableMode, View.FocusDirection, View.FocusRealDirection, View.LayoutDir, View.MeasureSpec, View.OnApplyWindowInsetsListener, 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.OnSystemUiVisibilityChangeListener, View.OnTouchListener, View.ResolvedLayoutDir, View.ScrollBarStyle, View.ScrollIndicators, View.TextAlignment, View.Visibility
Modifier and Type | Field and Description |
---|---|
protected static int |
CLIP_TO_PADDING_MASK
We clip to padding when FLAG_CLIP_TO_PADDING and FLAG_PADDING_NOT_NULL
are set at the same time.
|
static boolean |
DEBUG_DRAW |
protected static int |
FLAG_DISALLOW_INTERCEPT
When set, this ViewGroup should not intercept touch events.
|
protected static int |
FLAG_SUPPORT_STATIC_TRANSFORMATIONS
When set, this ViewGroup supports static transformations on children; this causes
getChildStaticTransformation(View, android.view.animation.Transformation) to be
invoked when a child is drawn. |
protected static int |
FLAG_USE_CHILD_DRAWING_ORDER
When set, the drawing method will call
getChildDrawingOrder(int, int)
to get the index of the child to draw for that iteration. |
static int |
FOCUS_AFTER_DESCENDANTS
This view will get focus only if none of its descendants want it.
|
static int |
FOCUS_BEFORE_DESCENDANTS
This view will get focus before any of its descendants.
|
static int |
FOCUS_BLOCK_DESCENDANTS
This view will block any of its descendants from getting focus, even
if they are focusable.
|
static int |
LAYOUT_MODE_CLIP_BOUNDS
This constant is a
layoutMode . |
static int |
LAYOUT_MODE_DEFAULT |
static int |
LAYOUT_MODE_OPTICAL_BOUNDS
This constant is a
layoutMode . |
protected ArrayList<View> |
mDisappearingChildren
Views which have been hidden or removed which need to be animated on
their way out.
|
protected int |
mGroupFlags
Internal flags.
|
protected ViewGroup.OnHierarchyChangeListener |
mOnHierarchyChangeListener
Listener used to propagate events indicating when children are added
and/or removed from a view group.
|
protected int |
mPersistentDrawingCache
Indicates which types of drawing caches are to be kept in memory.
|
static int |
PERSISTENT_ALL_CACHES
Used to indicate that all drawing caches should be kept in memory.
|
static int |
PERSISTENT_ANIMATION_CACHE
Used to indicate that the animation drawing cache should be kept in memory.
|
static int |
PERSISTENT_NO_CACHE
Used to indicate that no drawing cache should be kept in memory.
|
static int |
PERSISTENT_SCROLLING_CACHE
Used to indicate that the scrolling drawing cache should be kept in memory.
|
ACCESSIBILITY_CURSOR_POSITION_UNDEFINED, ACCESSIBILITY_LIVE_REGION_ASSERTIVE, ACCESSIBILITY_LIVE_REGION_NONE, ACCESSIBILITY_LIVE_REGION_POLITE, ALPHA, DEBUG_LAYOUT_PROPERTY, DRAG_FLAG_GLOBAL, DRAG_FLAG_GLOBAL_PERSISTABLE_URI_PERMISSION, DRAG_FLAG_GLOBAL_PREFIX_URI_PERMISSION, DRAG_FLAG_GLOBAL_URI_READ, DRAG_FLAG_GLOBAL_URI_WRITE, DRAG_FLAG_OPAQUE, DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, 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, FIND_VIEWS_WITH_ACCESSIBILITY_NODE_PROVIDERS, FIND_VIEWS_WITH_CONTENT_DESCRIPTION, FIND_VIEWS_WITH_TEXT, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, 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, IMPORTANT_FOR_ACCESSIBILITY_AUTO, IMPORTANT_FOR_ACCESSIBILITY_NO, IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS, IMPORTANT_FOR_ACCESSIBILITY_YES, INVISIBLE, KEEP_SCREEN_ON, LAYER_TYPE_HARDWARE, LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, LAYOUT_DIRECTION_UNDEFINED, mAttributes, mBottom, mCachingFailed, mContext, mCurrentAnimation, mDebugViewAttributes, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, mInputEventConsistencyVerifier, mLayoutParams, mLeft, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mParent, mRight, mScrollX, mScrollY, mTag, mTop, mUserPaddingBottom, mUserPaddingLeft, mUserPaddingRight, NAVIGATION_BAR_TRANSIENT, NAVIGATION_BAR_TRANSLUCENT, NAVIGATION_BAR_TRANSPARENT, NAVIGATION_BAR_UNHIDE, NO_ID, 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, PUBLIC_STATUS_BAR_VISIBILITY_MASK, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCREEN_STATE_OFF, SCREEN_STATE_ON, 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, SCROLLBAR_POSITION_DEFAULT, SCROLLBAR_POSITION_LEFT, SCROLLBAR_POSITION_RIGHT, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, sPreserveMarginParamsInLayoutParamConversion, STATUS_BAR_DISABLE_BACK, STATUS_BAR_DISABLE_CLOCK, STATUS_BAR_DISABLE_EXPAND, STATUS_BAR_DISABLE_HOME, STATUS_BAR_DISABLE_NOTIFICATION_ALERTS, STATUS_BAR_DISABLE_NOTIFICATION_ICONS, STATUS_BAR_DISABLE_NOTIFICATION_TICKER, STATUS_BAR_DISABLE_RECENT, STATUS_BAR_DISABLE_SEARCH, STATUS_BAR_DISABLE_SYSTEM_INFO, STATUS_BAR_HIDDEN, STATUS_BAR_TRANSIENT, STATUS_BAR_TRANSLUCENT, STATUS_BAR_TRANSPARENT, STATUS_BAR_UNHIDE, STATUS_BAR_VISIBLE, SYSTEM_UI_CLEARABLE_FLAGS, SYSTEM_UI_FLAG_FULLSCREEN, SYSTEM_UI_FLAG_HIDE_NAVIGATION, SYSTEM_UI_FLAG_IMMERSIVE, SYSTEM_UI_FLAG_IMMERSIVE_STICKY, SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_STABLE, SYSTEM_UI_FLAG_LIGHT_STATUS_BAR, SYSTEM_UI_FLAG_LOW_PROFILE, SYSTEM_UI_FLAG_VISIBLE, SYSTEM_UI_LAYOUT_FLAGS, SYSTEM_UI_TRANSPARENT, 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, TRANSLATION_X, TRANSLATION_Y, TRANSLATION_Z, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y, Z
Constructor and Description |
---|
ViewGroup(Context context) |
ViewGroup(Context context,
AttributeSet attrs) |
ViewGroup(Context context,
AttributeSet attrs,
int defStyleAttr) |
ViewGroup(Context context,
AttributeSet attrs,
int defStyleAttr,
int defStyleRes) |
Modifier and Type | Method and Description |
---|---|
void |
addChildrenForAccessibility(ArrayList<View> outChildren)
Adds the children of this View relevant for accessibility to the given list
as output.
|
void |
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.
|
boolean |
addStatesFromChildren()
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 |
addView(View child)
Adds a child view.
|
void |
addView(View child,
int index)
Adds a child view.
|
void |
addView(View child,
int width,
int height)
Adds a child view with this ViewGroup's default layout parameters and the
specified width and height.
|
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 |
attachLayoutAnimationParameters(View child,
ViewGroup.LayoutParams params,
int index,
int count)
Subclasses should override this method to set layout animation
parameters on the supplied child.
|
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.
|
ArrayList<View> |
buildTouchDispatchChildList()
Provide custom ordering of views in which the touch will be dispatched.
|
protected boolean |
canAnimate()
Indicates whether the view group has the ability to animate its children
after the first layout.
|
void |
captureTransitioningViews(List<View> transitioningViews)
Gets the Views in the hierarchy affected by entering and exiting Activity Scene transitions.
|
protected boolean |
checkLayoutParams(ViewGroup.LayoutParams p) |
void |
childDrawableStateChanged(View child)
If
addStatesFromChildren() is true, refreshes this group's
drawable state (to include the states from its children). |
void |
childHasTransientStateChanged(View child,
boolean childHasTransientState)
Called when a child view has changed whether or not it is tracking transient state.
|
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 focus
|
void |
clearDisappearingChildren()
Removes any pending animations for views that have been removed.
|
void |
clearFocus()
Called when this view wants to give up focus.
|
Bitmap |
createSnapshot(Bitmap.Config quality,
int backgroundColor,
boolean skipChildren)
Create a snapshot of the view into a bitmap.
|
void |
damageChild(View child,
Rect dirty)
Quick invalidation method called by View.invalidateViewProperty.
|
boolean |
damageChildDeferred(View child)
Native-calculated damage path
Returns false if this path was unable to complete successfully.
|
protected ViewParent |
damageChildInParent(int left,
int top,
Rect dirty)
Quick invalidation method that simply transforms the dirty rect into the parent's
coordinate system, pruning the invalidation if the parent has already been invalidated.
|
protected void |
debug(int depth)
Prints information about this view in the log output, with the tag
View.VIEW_LOG_TAG . |
protected void |
detachAllViewsFromParent()
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.
|
boolean |
dispatchActivityResult(String who,
int requestCode,
int resultCode,
Intent data)
If this View corresponds to the calling who, dispatches the activity result.
|
WindowInsets |
dispatchApplyWindowInsets(WindowInsets insets)
Request to apply the given window insets to this view or another view in its subtree.
|
void |
dispatchConfigurationChanged(Configuration newConfig)
Dispatch a notification about a resource configuration change down
the view hierarchy.
|
void |
dispatchDisplayHint(int hint)
Dispatch a hint about whether this view is displayed.
|
boolean |
dispatchDragEvent(DragEvent event)
Detects if this View is enabled and has a drag event listener.
|
protected void |
dispatchDraw(Canvas canvas)
Called by draw to draw the child views.
|
void |
dispatchDrawableHotspotChanged(float x,
float y)
Dispatches drawable hotspot changes to child views that meet at least
one of the following criteria:
Returns
false from both View.isClickable() and
View.isLongClickable()
Requests duplication of parent state via
View.setDuplicateParentStateEnabled(boolean)
|
void |
dispatchFinishTemporaryDetach()
Dispatch
View.onFinishTemporaryDetach() to this View and its direct children if this is
a container View. |
protected void |
dispatchFreezeSelfOnly(SparseArray<Parcelable> container)
Perform dispatching of a
View.saveHierarchyState(android.util.SparseArray) freeze()}
to only this view, not to its children. |
protected boolean |
dispatchGenericFocusedEvent(MotionEvent event)
Dispatch a generic motion event to the currently focused view.
|
protected boolean |
dispatchGenericPointerEvent(MotionEvent event)
Dispatch a generic motion event to the view under the first pointer.
|
protected void |
dispatchGetDisplayList()
This method is used to cause children of this ViewGroup to restore or recreate their
display lists.
|
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 |
dispatchKeyEventPreIme(KeyEvent event)
Dispatch a key event before it is processed by any input method
associated with the view hierarchy.
|
boolean |
dispatchKeyShortcutEvent(KeyEvent event)
Dispatches a key shortcut event.
|
boolean |
dispatchPopulateAccessibilityEventInternal(AccessibilityEvent event) |
void |
dispatchProvideStructure(ViewStructure structure)
Dispatch creation of
ViewStructure down the hierarchy. |
protected void |
dispatchRestoreInstanceState(SparseArray<Parcelable> container)
Called by
View.restoreHierarchyState(android.util.SparseArray) to retrieve the
state for this view and its children. |
protected void |
dispatchSaveInstanceState(SparseArray<Parcelable> container)
Called by
View.saveHierarchyState(android.util.SparseArray) to store the state for
this view and its children. |
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 |
dispatchStartTemporaryDetach()
Dispatch
View.onStartTemporaryDetach() to this View and its direct children if this is
a container View. |
void |
dispatchSystemUiVisibilityChanged(int visible)
Dispatch callbacks to
View.setOnSystemUiVisibilityChangeListener(android.view.View.OnSystemUiVisibilityChangeListener) down
the view hierarchy. |
protected void |
dispatchThawSelfOnly(SparseArray<Parcelable> container)
Perform dispatching of a
View.restoreHierarchyState(android.util.SparseArray)
to only this view, not to its children. |
boolean |
dispatchTouchEvent(MotionEvent ev)
Pass the touch screen motion event down to the target view, or this
view if it is the target.
|
boolean |
dispatchTrackballEvent(MotionEvent event)
Pass a trackball motion event down to the focused view.
|
boolean |
dispatchUnhandledMove(View focused,
int direction)
This method is the last chance for the focused view and its ancestors to
respond to an arrow key.
|
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 |
dispatchWindowSystemUiVisiblityChanged(int visible)
Dispatch callbacks to
View.onWindowSystemUiVisibilityChanged(int) down
the view hierarchy. |
void |
dispatchWindowVisibilityChanged(int visibility)
Dispatch a window visibility change down the view hierarchy.
|
protected void |
drawableStateChanged()
This function is called whenever the state of the view changes in such
a way that it impacts the state of drawables being shown.
|
protected boolean |
drawChild(Canvas canvas,
View child,
long drawingTime)
Draw one child of this View Group.
|
protected void |
encodeProperties(ViewHierarchyEncoder encoder) |
void |
endViewTransition(View view)
This method should always be called following an earlier call to
startViewTransition(View) . |
View |
findFocus()
Find the view in the hierarchy rooted at this view that currently has
focus.
|
void |
findNamedViews(Map<String,View> namedElements)
Adds all Views that have
View.getTransitionName() non-null to namedElements. |
View |
findViewByAccessibilityIdTraversal(int accessibilityId)
Performs the traversal to find a view by its unuque and stable accessibility id.
|
protected View |
findViewByPredicateTraversal(Predicate<View> predicate,
View childToSkip) |
void |
findViewsWithText(ArrayList<View> outViews,
CharSequence text,
int flags)
Finds the Views that contain given text.
|
protected View |
findViewTraversal(int id) |
protected View |
findViewWithTagTraversal(Object tag) |
void |
focusableViewAvailable(View v)
Tells the parent that a new focusable view has become available.
|
View |
focusSearch(View focused,
int direction)
Find the nearest view in the specified direction that wants to take
focus.
|
boolean |
gatherTransparentRegion(Region region)
This is used by the RootView to perform an optimization when
the view hierarchy contains one or several SurfaceView.
|
protected ViewGroup.LayoutParams |
generateDefaultLayoutParams()
Returns a set of default layout parameters.
|
ViewGroup.LayoutParams |
generateLayoutParams(AttributeSet attrs)
Returns a new set of layout parameters based on the supplied attributes set.
|
protected ViewGroup.LayoutParams |
generateLayoutParams(ViewGroup.LayoutParams p)
Returns a safe set of layout parameters based on the supplied layout params.
|
CharSequence |
getAccessibilityClassName()
Return the class name of this object to be used for accessibility purposes.
|
View |
getChildAt(int index)
Returns the view at the specified position in the group.
|
int |
getChildCount()
Returns the number of children in the group.
|
protected int |
getChildDrawingOrder(int childCount,
int i)
Returns the index of the child to draw for this iteration.
|
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.
|
protected boolean |
getChildStaticTransformation(View child,
Transformation t)
Sets
t to be the static transformation of the child, if set, returning a
boolean to indicate whether a static transform was set. |
boolean |
getChildVisibleRect(View child,
Rect r,
Point offset)
Compute the visible part of a rectangular region defined in terms of a child view's
coordinates.
|
boolean |
getChildVisibleRect(View child,
Rect r,
Point offset,
boolean forceParentCheck) |
boolean |
getClipChildren()
Returns whether this group's children are clipped to their bounds before drawing.
|
boolean |
getClipToPadding()
Returns whether this ViewGroup will clip its children to its padding, and resize (but
not clip) any EdgeEffect to the padded region, if padding is present.
|
int |
getDescendantFocusability()
Gets the descendant focusability of this view group.
|
View |
getFocusedChild()
Returns the focused child of this view, if any.
|
LayoutAnimationController |
getLayoutAnimation()
Returns the layout animation controller used to animate the group's
children.
|
Animation.AnimationListener |
getLayoutAnimationListener()
Returns the animation listener to which layout animation events are
sent.
|
int |
getLayoutMode()
Returns the basis of alignment during layout operations on this ViewGroup:
either
LAYOUT_MODE_CLIP_BOUNDS or LAYOUT_MODE_OPTICAL_BOUNDS . |
LayoutTransition |
getLayoutTransition()
Gets the LayoutTransition object for this ViewGroup.
|
int |
getNestedScrollAxes()
Return the current axes of nested scrolling for this ViewGroup.
|
ViewGroupOverlay |
getOverlay()
Returns the ViewGroupOverlay for this view group, creating it if it does
not yet exist.
|
int |
getPersistentDrawingCache()
Returns an integer indicating what types of drawing caches are kept in memory.
|
boolean |
getTouchscreenBlocksFocus()
Check whether this ViewGroup should ignore focus requests for itself and its children.
|
View |
getTransientView(int position)
Given a valid position within the list of transient views, returns the
transient view at that position.
|
int |
getTransientViewCount()
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.
|
boolean |
hasFocus()
Returns true if this view has or contains focus
|
boolean |
hasFocusable()
Returns true if this view is focusable or if it contains a reachable View
for which
View.hasFocusable() returns true. |
protected boolean |
hasHoveredChild()
Returns true if the view has a child to which it has recently sent
MotionEvent.ACTION_HOVER_ENTER . |
boolean |
hasTransientState()
Indicates whether the view is currently tracking transient state that the
app should not need to concern itself with saving and restoring, but that
the framework should take special note to preserve when possible.
|
int |
indexOfChild(View child)
Returns the position in the group of the specified child view.
|
protected void |
internalSetPadding(int left,
int top,
int right,
int bottom) |
void |
invalidateChild(View child,
Rect dirty)
Don't call or override this method.
|
ViewParent |
invalidateChildInParent(int[] location,
Rect dirty)
Don't call or override this method.
|
boolean |
isAlwaysDrawnWithCacheEnabled()
Deprecated.
As of
Build.VERSION_CODES.M , this property is ignored.
Child views may no longer have their caching behavior disabled by parents. |
boolean |
isAnimationCacheEnabled()
Deprecated.
As of
Build.VERSION_CODES.M , this property is ignored.
Caching behavior of children may be controlled through View.setLayerType(int, Paint) . |
protected boolean |
isChildrenDrawingOrderEnabled()
Indicates whether the ViewGroup is drawing its children in the order defined by
getChildDrawingOrder(int, int) . |
protected boolean |
isChildrenDrawnWithCacheEnabled()
Deprecated.
As of
Build.VERSION_CODES.M , this property is ignored.
Child views may no longer be forced to cache their rendering state by their parents.
Use View.setLayerType(int, Paint) on individual Views instead. |
boolean |
isLayoutSuppressed()
Returns whether layout calls on this container are currently being
suppressed, due to an earlier call to
suppressLayout(boolean) . |
boolean |
isMotionEventSplittingEnabled()
Returns true if MotionEvents dispatched to this ViewGroup can be split to multiple children.
|
boolean |
isShowingContextMenuWithCoords() |
protected boolean |
isTransformedTouchPointInView(float x,
float y,
View child,
PointF outLocalPoint)
Returns true if a child view contains the specified point when transformed
into its coordinate space.
|
boolean |
isTransitionGroup()
Returns true if this ViewGroup should be considered as a single entity for removal
when executing an Activity transition.
|
void |
jumpDrawablesToCurrentState()
Call
Drawable.jumpToCurrentState()
on all Drawable objects associated with this view. |
void |
layout(int l,
int t,
int r,
int b)
Assign a size and position to a view and all of its
descendants
This is the second phase of the layout mechanism.
|
void |
makeOptionalFitsSystemWindows()
For use by PhoneWindow to make its own system window fitting optional.
|
protected void |
measureChild(View child,
int parentWidthMeasureSpec,
int parentHeightMeasureSpec)
Ask one of the children of this view to measure itself, taking into
account both the MeasureSpec requirements for this view and its padding.
|
protected void |
measureChildren(int widthMeasureSpec,
int heightMeasureSpec)
Ask all of the children of this view to measure themselves, taking into
account both the MeasureSpec requirements for this view and its padding.
|
protected void |
measureChildWithMargins(View child,
int parentWidthMeasureSpec,
int widthUsed,
int parentHeightMeasureSpec,
int heightUsed)
Ask one of the children of this view to measure itself, taking into
account both the MeasureSpec requirements for this view and its padding
and margins.
|
void |
notifySubtreeAccessibilityStateChanged(View child,
View source,
int changeType)
Notifies a view parent that the accessibility state of one of its
descendants has changed and that the structure of the subtree is
different.
|
void |
offsetChildrenTopAndBottom(int offset)
Offset the vertical location of all children of this view by the specified number of pixels.
|
void |
offsetDescendantRectToMyCoords(View descendant,
Rect rect)
Offset a rectangle that is in a descendant's coordinate
space into our coordinate space.
|
void |
offsetRectIntoDescendantCoords(View descendant,
Rect rect)
Offset a rectangle that is in our coordinate space into an ancestor's
coordinate space.
|
protected void |
onAttachedToWindow()
This is called when the view is attached to a window.
|
protected void |
onChildVisibilityChanged(View child,
int oldVisibility,
int newVisibility)
Called when a view's visibility has changed.
|
protected int[] |
onCreateDrawableState(int extraSpace)
Generate the new
Drawable state for
this view. |
protected void |
onDebugDraw(Canvas canvas) |
protected void |
onDebugDrawMargins(Canvas canvas,
Paint paint) |
protected void |
onDetachedFromWindow()
This is called when the view is detached from a window.
|
void |
onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) |
boolean |
onInterceptHoverEvent(MotionEvent event)
Implement this method to intercept hover events before they are handled
by child views.
|
boolean |
onInterceptTouchEvent(MotionEvent ev)
Implement this method to intercept all touch screen motion events.
|
protected abstract void |
onLayout(boolean changed,
int l,
int t,
int r,
int b)
Called from layout when this view should
assign a size and position to each of its children.
|
boolean |
onNestedFling(View target,
float velocityX,
float velocityY,
boolean consumed)
Request a fling from a nested scroll.
|
boolean |
onNestedPreFling(View target,
float velocityX,
float velocityY)
React to a nested fling before the target view consumes it.
|
boolean |
onNestedPrePerformAccessibilityAction(View target,
int action,
Bundle args)
React to an accessibility action delegated by a target descendant view before the target
processes it.
|
void |
onNestedPreScroll(View target,
int dx,
int dy,
int[] consumed)
React to a nested scroll in progress before the target view consumes a portion of the scroll.
|
void |
onNestedScroll(View target,
int dxConsumed,
int dyConsumed,
int dxUnconsumed,
int dyUnconsumed)
React to a nested scroll in progress.
|
void |
onNestedScrollAccepted(View child,
View target,
int axes)
React to the successful claiming of a nested scroll operation.
|
protected boolean |
onRequestFocusInDescendants(int direction,
Rect previouslyFocusedRect)
Look for a descendant to call
View.requestFocus() on. |
boolean |
onRequestSendAccessibilityEvent(View child,
AccessibilityEvent event)
Called when a child has requested sending an
AccessibilityEvent and
gives an opportunity to its parent to augment the event. |
boolean |
onRequestSendAccessibilityEventInternal(View child,
AccessibilityEvent event) |
PointerIcon |
onResolvePointerIcon(MotionEvent event,
int pointerIndex)
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 nestedScrollAxes)
React to a descendant view initiating a nestable scroll operation, claiming the
nested scroll operation if appropriate.
|
void |
onStopNestedScroll(View child)
React to a nested scroll operation ending.
|
void |
onViewAdded(View child)
Called when a new child is added to this ViewGroup.
|
void |
onViewRemoved(View child)
Called when a child view is removed from this ViewGroup.
|
void |
recomputeViewAttributes(View child)
Tell view hierarchy that the global view attributes need to be
re-evaluated.
|
void |
removeAllViews()
Call this method to remove all child views from the
ViewGroup.
|
void |
removeAllViewsInLayout()
Called by a ViewGroup subclass to remove child views from itself,
when it must first know its size on screen before it can calculate how many
child views it will render.
|
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 from
View.draw(android.graphics.Canvas) , View.onDraw(android.graphics.Canvas) ,
dispatchDraw(android.graphics.Canvas) or any related method. |
void |
removeViewAt(int index)
Removes the view at the specified position in the group.
|
void |
removeViewInLayout(View view)
Removes a view during layout.
|
void |
removeViews(int start,
int count)
Removes the specified range of views from the group.
|
void |
removeViewsInLayout(int start,
int count)
Removes a range of views during layout.
|
void |
requestChildFocus(View child,
View focused)
Called when a child of this parent wants focus
|
boolean |
requestChildRectangleOnScreen(View child,
Rect rectangle,
boolean immediate)
Called when a child of this group wants a particular rectangle to be
positioned onto the screen.
|
void |
requestDisallowInterceptTouchEvent(boolean disallowIntercept)
Called when a child does not want this parent and its ancestors to
intercept touch events with
onInterceptTouchEvent(MotionEvent) . |
boolean |
requestFocus(int direction,
Rect previouslyFocusedRect)
Call this to try to give focus to a specific view or to one of its descendants
and give it hints about the direction and a specific rectangle that the focus
is coming from.
|
boolean |
requestSendAccessibilityEvent(View child,
AccessibilityEvent event)
Called by a child to request from its parent to send an
AccessibilityEvent . |
void |
requestTransitionStart(LayoutTransition transition)
This method is called by LayoutTransition when there are 'changing' animations that need
to start after the layout/setup phase.
|
void |
requestTransparentRegion(View child)
Called when a child wants the view hierarchy to gather and report
transparent regions to the window compositor.
|
protected void |
resetResolvedDrawables() |
void |
resetResolvedLayoutDirection()
Reset the resolved layout direction.
|
void |
resetResolvedPadding()
Reset the resolved layout direction.
|
void |
resetResolvedTextAlignment()
Reset resolved text alignment.
|
void |
resetResolvedTextDirection()
Reset resolved text direction.
|
protected void |
resolveDrawables()
Resolve the Drawables depending on the layout direction.
|
boolean |
resolveLayoutDirection()
Resolve and cache the layout direction.
|
void |
resolveLayoutParams()
Resolve the layout parameters depending on the resolved layout direction
|
void |
resolvePadding()
Resolves padding depending on layout direction, if applicable, and
recomputes internal padding values to adjust for scroll bars.
|
boolean |
resolveRtlPropertiesIfNeeded()
Resolve all RTL related properties.
|
boolean |
resolveTextAlignment()
Resolve the text alignment.
|
boolean |
resolveTextDirection()
Resolve the text direction.
|
void |
scheduleLayoutAnimation()
Schedules the layout animation to be played after the next layout pass
of this view group.
|
void |
setAddStatesFromChildren(boolean addsStates)
Sets whether this ViewGroup's drawable states also include
its children's drawable states.
|
void |
setAlwaysDrawnWithCacheEnabled(boolean always)
Deprecated.
As of
Build.VERSION_CODES.M , this property is ignored.
Child views may no longer have their caching behavior disabled by parents. |
void |
setAnimationCacheEnabled(boolean enabled)
Deprecated.
As of
Build.VERSION_CODES.M , this property is ignored.
Caching behavior of children may be controlled through View.setLayerType(int, Paint) . |
protected void |
setChildrenDrawingCacheEnabled(boolean enabled)
Enables or disables the drawing cache for each child of this view group.
|
protected void |
setChildrenDrawingOrderEnabled(boolean enabled)
Tells the ViewGroup whether to draw its children in the order defined by the method
getChildDrawingOrder(int, int) . |
protected void |
setChildrenDrawnWithCacheEnabled(boolean enabled)
Deprecated.
As of
Build.VERSION_CODES.M , this property is ignored.
Child views may no longer be forced to cache their rendering state by their parents.
Use View.setLayerType(int, Paint) on individual Views instead. |
void |
setClipChildren(boolean clipChildren)
By default, children are clipped to their bounds before drawing.
|
void |
setClipToPadding(boolean clipToPadding)
Sets whether this ViewGroup will clip its children to its padding and resize (but not
clip) any EdgeEffect to the padded region, if padding is present.
|
void |
setDescendantFocusability(int focusability)
Set the descendant focusability of this view group.
|
void |
setLayoutAnimation(LayoutAnimationController controller)
Sets the layout animation controller used to animate the group's
children after the first layout.
|
void |
setLayoutAnimationListener(Animation.AnimationListener animationListener)
Specifies the animation listener to which layout animation events must
be sent.
|
void |
setLayoutMode(int layoutMode)
Sets the basis of alignment during the layout of this ViewGroup.
|
void |
setLayoutTransition(LayoutTransition transition)
Sets the LayoutTransition object for this ViewGroup.
|
void |
setMotionEventSplittingEnabled(boolean split)
Enable or disable the splitting of MotionEvents to multiple children during touch event
dispatch.
|
void |
setOnHierarchyChangeListener(ViewGroup.OnHierarchyChangeListener listener)
Register a callback to be invoked when a child is added to or removed
from this view.
|
void |
setPersistentDrawingCache(int drawingCacheToKeep)
Indicates what types of drawing caches should be kept in memory after
they have been created.
|
protected void |
setStaticTransformationsEnabled(boolean enabled)
When this property is set to true, this ViewGroup supports static transformations on
children; this causes
getChildStaticTransformation(View, android.view.animation.Transformation) to be
invoked when a child is drawn. |
void |
setTouchscreenBlocksFocus(boolean touchscreenBlocksFocus)
Set whether this ViewGroup should ignore focus requests for itself and its children.
|
void |
setTransitionGroup(boolean isTransitionGroup)
Changes whether or not this ViewGroup should be treated as a single entity during
Activity Transitions.
|
boolean |
shouldDelayChildPressedState()
Return true if the pressed state should be delayed for children or descendants of this
ViewGroup.
|
boolean |
showContextMenuForChild(View originalView)
Shows the context menu for the specified view or its ancestors.
|
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.
|
ActionMode |
startActionModeForChild(View originalView,
ActionMode.Callback callback)
Start an action mode for the specified view with the default type
ActionMode.TYPE_PRIMARY . |
ActionMode |
startActionModeForChild(View originalView,
ActionMode.Callback callback,
int type)
Start an action mode of a specific type for the specified view.
|
void |
startLayoutAnimation()
Runs the layout animation.
|
void |
startViewTransition(View view)
This method tells the ViewGroup that the given View object, which should have this
ViewGroup as its parent,
should be kept around (re-displayed when the ViewGroup draws its children) even if it
is removed from its parent.
|
void |
suppressLayout(boolean suppress)
Tells this ViewGroup to suppress all layout() calls until layout
suppression is disabled with a later call to suppressLayout(false).
|
void |
transformPointToViewLocal(float[] point,
View child) |
void |
updateViewLayout(View view,
ViewGroup.LayoutParams params) |
addFocusables, addFrameMetricsListener, addOnAttachStateChangeListener, addOnLayoutChangeListener, animate, announceForAccessibility, applyDrawableToTransparentRegion, awakenScrollBars, awakenScrollBars, awakenScrollBars, bringToFront, buildDrawingCache, buildDrawingCache, buildLayer, callOnClick, cancelDragAndDrop, cancelLongPress, cancelPendingInputEvents, canHaveDisplayList, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, checkInputConnectionProxy, clearAccessibilityFocus, clearAnimation, combineMeasuredStates, computeFitSystemWindows, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeOpaqueFlags, computeScroll, computeSystemWindowInsets, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createAccessibilityNodeInfo, createAccessibilityNodeInfoInternal, createContextMenu, damageInParent, debug, debugIndent, destroyDrawingCache, destroyHardwareResources, dispatchGenericMotionEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPointerEvent, dispatchPopulateAccessibilityEvent, draw, drawableHotspotChanged, encode, findViewById, findViewByPredicate, findViewByPredicateInsideOut, findViewWithTag, fitsSystemWindows, fitSystemWindows, focusSearch, forceHasOverlappingRendering, forceLayout, generateViewId, getAccessibilityDelegate, getAccessibilityLiveRegion, getAccessibilityNodeProvider, getAccessibilitySelectionEnd, getAccessibilitySelectionStart, getAccessibilityTraversalAfter, getAccessibilityTraversalBefore, getAccessibilityViewId, getAccessibilityWindowId, getAlpha, getAnimation, getApplicationWindowToken, getBackground, getBackgroundTintList, getBackgroundTintMode, getBaseline, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getBoundsOnScreen, getBoundsOnScreen, getCameraDistance, getClipBounds, getClipBounds, getClipToOutline, getContentDescription, getContext, getContextMenuInfo, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getElevation, getFadeHeight, getFadeTop, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getForegroundTintList, getForegroundTintMode, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHardwareRenderer, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getHorizontalScrollFactor, getHotspotBounds, getId, getImportantForAccessibility, getInverseMatrix, getIterableTextForAccessibility, getIteratorForGranularity, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLocalVisibleRect, getLocationInSurface, getLocationInWindow, getLocationOnScreen, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOpticalInsets, getOutlineProvider, getOutsets, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getPointerIcon, getRawLayoutDirection, getRawTextAlignment, getRawTextDirection, getResources, getRevealOnFocusHint, getRight, getRightFadingEdgeStrength, getRightPaddingOffset, getRootView, getRootWindowInsets, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollIndicators, getScrollX, getScrollY, getSolidColor, getStateListAnimator, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getSystemUiVisibility, getTag, getTag, getTextAlignment, getTextDirection, getTop, getTopFadingEdgeStrength, getTopPaddingOffset, getTouchables, getTouchDelegate, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarWidth, getVerticalScrollFactor, getViewRootImpl, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowDisplayFrame, getWindowId, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, getZ, handleScrollBarDragging, hasNestedScrollingParent, hasOnClickListeners, hasOpaqueScrollbars, hasOverlappingRendering, hasShadow, hasWindowFocus, includeForAccessibility, inflate, initializeFadingEdge, initializeFadingEdgeInternal, initializeScrollbars, initializeScrollbarsInternal, invalidate, invalidate, invalidate, invalidateDrawable, invalidateOutline, invalidateParentCaches, invalidateParentIfNeeded, invalidateParentIfNeededAndWasQuickRejected, isAccessibilityFocused, isAccessibilitySelectionExtendable, isActionableForAccessibility, isActivated, isAssistBlocked, isAttachedToWindow, isClickable, isContextClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isForegroundInsidePadding, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isInEditMode, isInLayout, isInScrollingContainer, isInTouchMode, isLaidOut, isLayoutDirectionInherited, isLayoutDirectionResolved, isLayoutModeOptical, isLayoutRequested, isLayoutRtl, isLongClickable, isNestedScrollingEnabled, isOpaque, isPaddingOffsetRequired, isPaddingRelative, isPressed, isRootNamespace, isSaveEnabled, isSaveFromParentEnabled, isScrollbarFadingEnabled, isScrollContainer, isSelected, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentInherited, isTextAlignmentResolved, isTextDirectionInherited, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVerticalScrollBarHidden, isVisibleToUser, isVisibleToUser, measure, mergeDrawableStates, notifySubtreeAccessibilityStateChangedIfNeeded, notifyViewAccessibilityStateChangedIfNeeded, offsetLeftAndRight, offsetTopAndBottom, onActivityResult, onAnimationEnd, onAnimationStart, onApplyWindowInsets, onCancelPendingInputEvents, onCheckIsTextEditor, onCloseSystemDialogs, onConfigurationChanged, onCreateContextMenu, onCreateInputConnection, onDetachedFromWindowInternal, onDisplayHint, onDragEvent, onDraw, onDrawForeground, onDrawHorizontalScrollBar, onDrawScrollBars, onDrawVerticalScrollBar, onFilterTouchEventForSecurity, onFinishInflate, onFinishTemporaryDetach, onFocusChanged, onFocusLost, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityEventInternal, onInitializeAccessibilityNodeInfo, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onMeasure, onOverScrolled, onPopulateAccessibilityEvent, onPopulateAccessibilityEventInternal, onProvideStructure, onProvideVirtualStructure, onRenderNodeDetached, onResolveDrawables, onRestoreInstanceState, onRtlPropertiesChanged, onSaveInstanceState, onScreenStateChanged, onScrollChanged, onSetAlpha, onSizeChanged, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onVisibilityAggregated, onVisibilityChanged, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, onWindowVisibilityChanged, outputDirtyFlags, overScrollBy, performAccessibilityAction, performAccessibilityActionInternal, performButtonActionOnTouchDown, performClick, performContextClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, performLongClick, playSoundEffect, pointInView, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, postInvalidateOnAnimation, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, recomputePadding, refreshDrawableState, removeCallbacks, removeFrameMetricsListener, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestAccessibilityFocus, requestApplyInsets, requestFitSystemWindows, requestFocus, requestFocus, requestFocusFromTouch, requestKeyboardShortcuts, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, requestUnbufferedDispatch, resetPaddingToInitialValues, resetRtlProperties, resolveSize, resolveSizeAndState, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventInternal, sendAccessibilityEventUnchecked, sendAccessibilityEventUncheckedInternal, setAccessibilityDelegate, setAccessibilityLiveRegion, setAccessibilitySelection, setAccessibilityTraversalAfter, setAccessibilityTraversalBefore, setActivated, setAlpha, setAnimation, setAnimationMatrix, setAssistBlocked, setBackground, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBackgroundTintList, setBackgroundTintMode, setBottom, setCameraDistance, setClickable, setClipBounds, setClipToOutline, setContentDescription, setContextClickable, setDisabledSystemUiVisibility, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setElevation, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusableInTouchMode, setForeground, setForegroundGravity, setForegroundTintList, setForegroundTintMode, setFrame, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHovered, setId, setImportantForAccessibility, setIsRootNamespace, setKeepScreenOn, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutParams, setLeft, setLeftTopRightBottom, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnApplyWindowInsetsListener, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOpticalInsets, setOutlineProvider, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPointerIcon, setPressed, setRevealClip, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollContainer, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setStateListAnimator, setSystemUiVisibility, setTag, setTag, setTagInternal, setTextAlignment, setTextDirection, setTop, setTouchDelegate, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, setZ, showContextMenu, showContextMenu, startActionMode, startActionMode, startActivityForResult, startAnimation, startDrag, startDragAndDrop, startMovingTask, startNestedScroll, stopNestedScroll, toGlobalMotionEvent, toLocalMotionEvent, toString, transformFromViewToWindowSpace, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, unscheduleDrawable, updateDisplayListIfDirty, updateDragShadow, verifyDrawable, willNotCacheDrawing, willNotDraw
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, createContextMenu, getLayoutDirection, getParent, getParentForAccessibility, getTextAlignment, getTextDirection, isLayoutDirectionResolved, isLayoutRequested, isTextAlignmentResolved, isTextDirectionResolved, requestFitSystemWindows, requestLayout
public static boolean DEBUG_DRAW
protected ArrayList<View> mDisappearingChildren
protected ViewGroup.OnHierarchyChangeListener mOnHierarchyChangeListener
protected int mGroupFlags
protected static final int FLAG_USE_CHILD_DRAWING_ORDER
getChildDrawingOrder(int, int)
to get the index of the child to draw for that iteration.protected static final int FLAG_SUPPORT_STATIC_TRANSFORMATIONS
getChildStaticTransformation(View, android.view.animation.Transformation)
to be
invoked when a child is drawn.
Any subclass overriding
getChildStaticTransformation(View, android.view.animation.Transformation)
should
set this flags in mGroupFlags
.
public static final int FOCUS_BEFORE_DESCENDANTS
public static final int FOCUS_AFTER_DESCENDANTS
public static final int FOCUS_BLOCK_DESCENDANTS
protected static final int FLAG_DISALLOW_INTERCEPT
protected int mPersistentDrawingCache
public static final int PERSISTENT_NO_CACHE
public static final int PERSISTENT_ANIMATION_CACHE
public static final int PERSISTENT_SCROLLING_CACHE
public static final int PERSISTENT_ALL_CACHES
public static final int LAYOUT_MODE_CLIP_BOUNDS
public static final int LAYOUT_MODE_OPTICAL_BOUNDS
layoutMode
.
Optical bounds describe where a widget appears to be. They sit inside the clip
bounds which need to cover a larger area to allow other effects,
such as shadows and glows, to be drawn.public static int LAYOUT_MODE_DEFAULT
protected static final int CLIP_TO_PADDING_MASK
public ViewGroup(Context context)
public ViewGroup(Context context, AttributeSet attrs)
public ViewGroup(Context context, AttributeSet attrs, int defStyleAttr)
public ViewGroup(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
public int getDescendantFocusability()
requestFocus(int, android.graphics.Rect)
.FOCUS_BEFORE_DESCENDANTS
, FOCUS_AFTER_DESCENDANTS
,
FOCUS_BLOCK_DESCENDANTS
.public void setDescendantFocusability(int focusability)
requestFocus(int, android.graphics.Rect)
.focusability
- one of FOCUS_BEFORE_DESCENDANTS
, FOCUS_AFTER_DESCENDANTS
,
FOCUS_BLOCK_DESCENDANTS
.public void requestChildFocus(View child, View focused)
ViewParent
requestChildFocus
in interface ViewParent
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
focuspublic void focusableViewAvailable(View v)
ViewParent
focusableViewAvailable
in interface ViewParent
v
- The view that has become newly focusablepublic boolean showContextMenuForChild(View originalView)
ViewParent
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, android.view.ViewGroup.LayoutParams)
)
then it should override this and show the context menu.
showContextMenuForChild
in interface ViewParent
originalView
- the source view where the context menu was first
invokedtrue
if the context menu was shown, false
otherwiseViewParent.showContextMenuForChild(View, float, float)
public final boolean isShowingContextMenuWithCoords()
public boolean showContextMenuForChild(View originalView, float x, float y)
ViewParent
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, android.view.ViewGroup.LayoutParams)
)
then it should override this and show the context menu.
If a subclass overrides this method it should also override
ViewParent.showContextMenuForChild(View)
.
showContextMenuForChild
in interface ViewParent
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, or Float.NaN
to
disable anchoringy
- the Y coordinate in pixels relative to the original view to
which the menu should be anchored, or Float.NaN
to
disable anchoringtrue
if the context menu was shown, false
otherwisepublic ActionMode startActionModeForChild(View originalView, ActionMode.Callback callback)
ViewParent
ActionMode.TYPE_PRIMARY
.
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, android.view.ViewGroup.LayoutParams)
)
then it should override this and start the action mode.
startActionModeForChild
in interface ViewParent
originalView
- The source view where the action mode was first invokedcallback
- The callback that will handle lifecycle events for the action modeViewParent.startActionModeForChild(View, android.view.ActionMode.Callback, int)
public ActionMode startActionModeForChild(View originalView, ActionMode.Callback callback, int type)
ViewParent
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, android.view.ViewGroup.LayoutParams)
)
then it should override this and start the action mode.
startActionModeForChild
in interface ViewParent
originalView
- The source view where the action mode was first invokedcallback
- The callback that will handle lifecycle events for the action modetype
- One of ActionMode.TYPE_PRIMARY
or ActionMode.TYPE_FLOATING
.public boolean dispatchActivityResult(String who, int requestCode, int resultCode, Intent data)
View
dispatchActivityResult
in class View
who
- The identifier for the targeted View to receive the result.requestCode
- The integer request code originally supplied to
startActivityForResult(), allowing you to identify who this
result came from.resultCode
- The integer result code returned by the child activity
through its setResult().data
- An Intent, which can return result data to the caller
(various data can be attached to Intent "extras").true
if the activity result was dispatched.public View focusSearch(View focused, int direction)
focusSearch
in interface ViewParent
focused
- The view that currently has focusdirection
- One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and
FOCUS_RIGHT, or 0 for not applicable.public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate)
ViewParent
ViewGroup
s overriding this can trust
that:
ViewGroup
s overriding this should uphold the contract:
requestChildRectangleOnScreen
in interface ViewParent
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 otherwisepublic boolean requestSendAccessibilityEvent(View child, AccessibilityEvent event)
ViewParent
AccessibilityEvent
.
The child has already populated a record for itself in the event and is delegating
to its parent to send the event. The parent can optionally add a record for itself.
Note: An accessibility event is fired by an individual view which populates the event with a record for its state and requests from its parent to perform the sending. The parent can optionally add a record for itself before dispatching the request to its parent. A parent can also choose not to respect the request for sending the event. The accessibility event is sent by the topmost view in the view tree.
requestSendAccessibilityEvent
in interface ViewParent
child
- The child which requests sending the event.event
- The event to be sent.public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event)
AccessibilityEvent
and
gives an opportunity to its parent to augment the event.
If an View.AccessibilityDelegate
has been specified via calling
View.setAccessibilityDelegate(android.view.View.AccessibilityDelegate)
its
View.AccessibilityDelegate.onRequestSendAccessibilityEvent(ViewGroup, View, AccessibilityEvent)
is responsible for handling this call.
child
- The child which requests sending the event.event
- The event to be sent.requestSendAccessibilityEvent(View, AccessibilityEvent)
public boolean onRequestSendAccessibilityEventInternal(View child, AccessibilityEvent event)
public void childHasTransientStateChanged(View child, boolean childHasTransientState)
childHasTransientStateChanged
in interface ViewParent
child
- Child view whose state has changedchildHasTransientState
- true if this child has transient statepublic boolean hasTransientState()
View
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.
hasTransientState
in class View
public boolean dispatchUnhandledMove(View focused, int direction)
View
dispatchUnhandledMove
in class View
focused
- The currently focused view.direction
- The direction focus wants to move. One of FOCUS_UP,
FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT.public void clearChildFocus(View child)
ViewParent
clearChildFocus
in interface ViewParent
child
- The view that is giving up focuspublic void clearFocus()
View
View.onFocusChanged(boolean, int, android.graphics.Rect)
is called.
Note: When a View clears focus the framework is trying to give focus to the first focusable View from the top. 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.
clearFocus
in class View
public View getFocusedChild()
public boolean hasFocus()
public View findFocus()
View
public boolean hasFocusable()
View
View.hasFocusable()
returns true. A "reachable hasFocusable()"
is a View whose parents do not block descendants focus.
Only View.VISIBLE
views are considered focusable.hasFocusable
in class View
FOCUS_BLOCK_DESCENDANTS
,
getTouchscreenBlocksFocus()
public void addFocusables(ArrayList<View> views, int direction, int focusableMode)
View
addFocusables
in class View
views
- Focusable views found so far or null if all we are interested is
the number of focusables.direction
- The direction of the focus.focusableMode
- The type of focusables to be added.View.FOCUSABLES_ALL
,
View.FOCUSABLES_TOUCH_MODE
public void setTouchscreenBlocksFocus(boolean touchscreenBlocksFocus)
touchscreenBlocksFocus
- true to enable blocking focus in the presence of a touchscreenpublic boolean getTouchscreenBlocksFocus()
public void findViewsWithText(ArrayList<View> outViews, CharSequence text, int flags)
View
View.FIND_VIEWS_WITH_TEXT
and
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION
flags.findViewsWithText
in class View
outViews
- The output list of matching Views.text
- The text to match against.View.FIND_VIEWS_WITH_TEXT
,
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION
,
View.setContentDescription(CharSequence)
public View findViewByAccessibilityIdTraversal(int accessibilityId)
View
findViewByAccessibilityIdTraversal
in class View
accessibilityId
- The accessibility id.public void dispatchWindowFocusChanged(boolean hasFocus)
View
dispatchWindowFocusChanged
in class View
hasFocus
- True if the window containing this view now has focus,
false otherwise.public void addTouchables(ArrayList<View> views)
View
addTouchables
in class View
views
- Touchable views found so farpublic void makeOptionalFitsSystemWindows()
View
makeOptionalFitsSystemWindows
in class View
public void dispatchDisplayHint(int hint)
View
dispatchDisplayHint
in class View
hint
- A hint about whether or not this view is displayed:
View.VISIBLE
or View.INVISIBLE
.protected void onChildVisibilityChanged(View child, int oldVisibility, int newVisibility)
child
- The view whose visibility has changedoldVisibility
- The previous visibility value (GONE, INVISIBLE, or VISIBLE).newVisibility
- The new visibility value (GONE, INVISIBLE, or VISIBLE).protected void dispatchVisibilityChanged(View changedView, int visibility)
View
dispatchVisibilityChanged
in class View
changedView
- The view whose visibility changed. Could be 'this' or
an ancestor view.visibility
- The new visibility of changedView: View.VISIBLE
,
View.INVISIBLE
or View.GONE
.public void dispatchWindowVisibilityChanged(int visibility)
View
dispatchWindowVisibilityChanged
in class View
visibility
- The new visibility of the window.View.onWindowVisibilityChanged(int)
public void dispatchConfigurationChanged(Configuration newConfig)
View
dispatchConfigurationChanged
in class View
newConfig
- The new resource configuration.View.onConfigurationChanged(android.content.res.Configuration)
public void recomputeViewAttributes(View child)
ViewParent
recomputeViewAttributes
in interface ViewParent
child
- View whose attributes have changed.public void bringChildToFront(View child)
ViewParent
Build.VERSION_CODES.KITKAT
this
method should be followed by calls to ViewParent.requestLayout()
and
View.invalidate()
on this parent to force the parent to redraw
with the new child ordering.bringChildToFront
in interface ViewParent
child
- The child to bring to the top of the z orderpublic boolean dispatchDragEvent(DragEvent event)
View
DragEvent
it received. If the drag event listener returns
true
, then dispatchDragEvent() returns true
.
For all other cases, the method calls the
onDragEvent()
drag event handler
method and returns its result.
This ensures that a drag event is always consumed, even if the View does not have a drag event listener. However, if the View has a listener and the listener returns true, then onDragEvent() is not called.
dispatchDragEvent
in class View
public void dispatchWindowSystemUiVisiblityChanged(int visible)
View
View.onWindowSystemUiVisibilityChanged(int)
down
the view hierarchy.dispatchWindowSystemUiVisiblityChanged
in class View
public void dispatchSystemUiVisibilityChanged(int visible)
View
View.setOnSystemUiVisibilityChangeListener(android.view.View.OnSystemUiVisibilityChangeListener)
down
the view hierarchy.dispatchSystemUiVisibilityChanged
in class View
public boolean dispatchKeyEventPreIme(KeyEvent event)
View
dispatchKeyEventPreIme
in class View
event
- The key event to be dispatched.public boolean dispatchKeyEvent(KeyEvent event)
View
dispatchKeyEvent
in class View
event
- The key event to be dispatched.public boolean dispatchKeyShortcutEvent(KeyEvent event)
View
dispatchKeyShortcutEvent
in class View
event
- The key event to be dispatched.public boolean dispatchTrackballEvent(MotionEvent event)
View
dispatchTrackballEvent
in class View
event
- The motion event to be dispatched.public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex)
View
onResolvePointerIcon
in class View
event
- The MotionEvent from a mousepointerIndex
- The index of the pointer for which to retrieve the PointerIcon
.
This will be between 0 and MotionEvent.getPointerCount()
.PointerIcon
protected boolean dispatchHoverEvent(MotionEvent event)
View
Do not call this method directly.
Call View.dispatchGenericMotionEvent(MotionEvent)
instead.
dispatchHoverEvent
in class View
event
- The motion event to be dispatched.protected boolean hasHoveredChild()
View
MotionEvent.ACTION_HOVER_ENTER
. If this view is hovered and
it does not have a hovered child, then it must be the innermost hovered view.hasHoveredChild
in class View
public void addChildrenForAccessibility(ArrayList<View> outChildren)
View
addChildrenForAccessibility
in class View
outChildren
- The output list that will receive children for accessibility.public boolean onInterceptHoverEvent(MotionEvent event)
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(android.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 return true
from onInterceptHoverEvent(android.view.MotionEvent)
for as long as it wishes to continue intercepting hover events from
its children.
Interception preserves the invariant that at most one view can be hovered at a time by transferring hover focus from the currently hovered child to the view group or vice-versa as needed.
If this method returns true
and a child is already hovered, then the
child view will first receive a hover exit event and then the view group
itself will receive a hover enter event in View.onHoverEvent(android.view.MotionEvent)
.
Likewise, if this method had previously returned true
to intercept hover
events and instead returns false
while the pointer is hovering
within the bounds of one of a child, then the view group will first receive a
hover exit event in View.onHoverEvent(android.view.MotionEvent)
and then the hovered child will
receive a hover enter event.
The default implementation handles mouse hover on the scroll bars.
event
- The motion event that describes the hover.protected boolean dispatchGenericPointerEvent(MotionEvent event)
View
Do not call this method directly.
Call View.dispatchGenericMotionEvent(MotionEvent)
instead.
dispatchGenericPointerEvent
in class View
event
- The motion event to be dispatched.protected boolean dispatchGenericFocusedEvent(MotionEvent event)
View
Do not call this method directly.
Call View.dispatchGenericMotionEvent(MotionEvent)
instead.
dispatchGenericFocusedEvent
in class View
event
- The motion event to be dispatched.public boolean dispatchTouchEvent(MotionEvent ev)
View
dispatchTouchEvent
in class View
ev
- The motion event to be dispatched.public ArrayList<View> buildTouchDispatchChildList()
protected boolean isTransformedTouchPointInView(float x, float y, View child, PointF outLocalPoint)
public void transformPointToViewLocal(float[] point, View child)
public void setMotionEventSplittingEnabled(boolean split)
Build.VERSION_CODES#HONEYCOMB
or newer.
When this option is enabled MotionEvents may be split and dispatched to different child views depending on where each pointer initially went down. This allows for user interactions such as scrolling two panes of content independently, chording of buttons, and performing independent gestures on different pieces of content.
split
- true
to allow MotionEvents to be split and dispatched to multiple
child views. false
to only allow one child view to be the target of
any MotionEvent received by this ViewGroup.public boolean isMotionEventSplittingEnabled()
public boolean isTransitionGroup()
View.getTransitionName()
is not null or if a
non-null ViewOutlineProvider
other than
ViewOutlineProvider.BACKGROUND
was given to
View.setOutlineProvider(ViewOutlineProvider)
and false otherwise.public void setTransitionGroup(boolean isTransitionGroup)
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.ActivityOptions.makeSceneTransitionAnimation(android.app.Activity,
android.util.Pair[])
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept)
ViewParent
onInterceptTouchEvent(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.
requestDisallowInterceptTouchEvent
in interface ViewParent
disallowIntercept
- True if the child does not want the parent to
intercept touch events.public boolean onInterceptTouchEvent(MotionEvent ev)
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:
MotionEvent.ACTION_CANCEL
, and all further
events will be delivered to your onTouchEvent() method and no longer
appear here.
ev
- The motion event being dispatched down the hierarchy.public boolean requestFocus(int direction, Rect previouslyFocusedRect)
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 to
FOCUS_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 internal
View
that it wishes to forward the request to.
Looks for a view to give focus to respecting the setting specified by
getDescendantFocusability()
.
Uses onRequestFocusInDescendants(int, android.graphics.Rect)
to
find focus within the children of this group when appropriate.requestFocus
in class View
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.FOCUS_BEFORE_DESCENDANTS
,
FOCUS_AFTER_DESCENDANTS
,
FOCUS_BLOCK_DESCENDANTS
,
onRequestFocusInDescendants(int, android.graphics.Rect)
protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect)
View.requestFocus()
on.
Called by requestFocus(int, android.graphics.Rect)
when it wants to request focus within its children. Override this to
customize how your ViewGroup
requests focus within its children.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.public void dispatchStartTemporaryDetach()
View.onStartTemporaryDetach()
to this View and its direct children if this is
a container View.dispatchStartTemporaryDetach
in class View
public void dispatchFinishTemporaryDetach()
View.onFinishTemporaryDetach()
to this View and its direct children if this is
a container View.dispatchFinishTemporaryDetach
in class View
public boolean dispatchPopulateAccessibilityEventInternal(AccessibilityEvent event)
dispatchPopulateAccessibilityEventInternal
in class View
Note: Called from the default {@link AccessibilityDelegate}.
public void dispatchProvideStructure(ViewStructure structure)
ViewStructure
down the hierarchy. This implementation
adds in all child views of the view group, in addition to calling the default View
implementation.dispatchProvideStructure
in class View
public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info)
onInitializeAccessibilityNodeInfoInternal
in class View
Note: Called from the default {@link AccessibilityDelegate}.
public CharSequence getAccessibilityClassName()
View
AccessibilityNodeInfo.setClassName
.getAccessibilityClassName
in class View
public void notifySubtreeAccessibilityStateChanged(View child, View source, int changeType)
ViewParent
notifySubtreeAccessibilityStateChanged
in interface ViewParent
child
- The direct child whose subtree has changed.source
- The descendant view that changed.changeType
- A bit mask of the types of changes that occurred. One
or more of:
public boolean onNestedPrePerformAccessibilityAction(View target, int action, Bundle args)
This method may be called by a target descendant view if the target wishes to give
a view in its parent chain a chance to react to the event before normal processing occurs.
Most commonly this will be a scroll event such as
AccessibilityNodeInfo.ACTION_SCROLL_FORWARD
.
A ViewParent that supports acting as a nested scrolling parent should override this
method and act accordingly to implement scrolling via accesibility systems.
Subclasses should always call super.onNestedPrePerformAccessibilityAction
onNestedPrePerformAccessibilityAction
in interface ViewParent
target
- The target view dispatching this actionaction
- Action being performed; see
AccessibilityNodeInfo
args
- Optional action argumentsprotected void internalSetPadding(int left, int top, int right, int bottom)
internalSetPadding
in class View
protected void dispatchSaveInstanceState(SparseArray<Parcelable> container)
View
View.saveHierarchyState(android.util.SparseArray)
to store the state for
this view and its children. May be overridden to modify how freezing happens to a
view's children; for example, some views may want to not store state for their children.dispatchSaveInstanceState
in class View
container
- The SparseArray in which to save the view's state.View.dispatchRestoreInstanceState(android.util.SparseArray)
,
View.saveHierarchyState(android.util.SparseArray)
,
View.onSaveInstanceState()
protected void dispatchFreezeSelfOnly(SparseArray<Parcelable> container)
View.saveHierarchyState(android.util.SparseArray)
freeze()}
to only this view, not to its children. For use when overriding
dispatchSaveInstanceState(android.util.SparseArray)
dispatchFreeze()} to allow
subclasses to freeze their own state but not the state of their children.container
- the containerprotected void dispatchRestoreInstanceState(SparseArray<Parcelable> container)
View
View.restoreHierarchyState(android.util.SparseArray)
to retrieve the
state for this view and its children. May be overridden to modify how restoring
happens to a view's children; for example, some views may want to not store state
for their children.dispatchRestoreInstanceState
in class View
container
- The SparseArray which holds previously saved state.View.dispatchSaveInstanceState(android.util.SparseArray)
,
View.restoreHierarchyState(android.util.SparseArray)
,
View.onRestoreInstanceState(android.os.Parcelable)
protected void dispatchThawSelfOnly(SparseArray<Parcelable> container)
View.restoreHierarchyState(android.util.SparseArray)
to only this view, not to its children. For use when overriding
dispatchRestoreInstanceState(android.util.SparseArray)
to allow
subclasses to thaw their own state but not the state of their children.container
- the containerprotected void setChildrenDrawingCacheEnabled(boolean enabled)
enabled
- true to enable the cache, false to dispose of itpublic Bitmap createSnapshot(Bitmap.Config quality, int backgroundColor, boolean skipChildren)
View
createSnapshot
in class View
protected void onDebugDraw(Canvas canvas)
protected void dispatchDraw(Canvas canvas)
View
dispatchDraw
in class View
canvas
- the canvas on which to draw the viewpublic ViewGroupOverlay getOverlay()
ViewOverlay
's support for drawables,
ViewGroupOverlay
allows views to be added to the overlay. These
views, like overlay drawables, are visual-only; they do not receive input
events and should not be used as anything other than a temporary
representation of a view in a parent container, such as might be used
by an animation effect.
Note: Overlays do not currently work correctly with SurfaceView
or TextureView
; contents in overlays for these
types of views may not display correctly.
getOverlay
in class View
ViewGroupOverlay
protected int getChildDrawingOrder(int childCount, int i)
NOTE: In order for this method to be called, you must enable child ordering
first by calling setChildrenDrawingOrderEnabled(boolean)
.
i
- The current iteration.setChildrenDrawingOrderEnabled(boolean)
,
isChildrenDrawingOrderEnabled()
protected void dispatchGetDisplayList()
dispatchGetDisplayList
in class View
protected boolean drawChild(Canvas canvas, View child, long drawingTime)
canvas
- The canvas on which to draw the childchild
- Who to drawdrawingTime
- The time at which draw is occurringpublic boolean getClipChildren()
setClipChildren(boolean)
public void setClipChildren(boolean clipChildren)
clipChildren
- true to clip children to their bounds,
false otherwisepublic void setClipToPadding(boolean clipToPadding)
By default, children are clipped to the padding of their parent ViewGroup. This clipping behavior is only enabled if padding is non-zero.
clipToPadding
- true to clip children to the padding of the group, and resize (but
not clip) any EdgeEffect to the padded region. False otherwise.public boolean getClipToPadding()
By default, children are clipped to the padding of their parent Viewgroup. This clipping behavior is only enabled if padding is non-zero.
public void dispatchSetSelected(boolean selected)
View
dispatchSetSelected
in class View
selected
- The new selected stateView.setSelected(boolean)
public void dispatchSetActivated(boolean activated)
View
dispatchSetActivated
in class View
activated
- The new activated stateView.setActivated(boolean)
protected void dispatchSetPressed(boolean pressed)
View
dispatchSetPressed
in class View
pressed
- The new pressed stateView.setPressed(boolean)
public void dispatchDrawableHotspotChanged(float x, float y)
false
from both View.isClickable()
and
View.isLongClickable()
View.setDuplicateParentStateEnabled(boolean)
dispatchDrawableHotspotChanged
in class View
x
- hotspot x coordinatey
- hotspot y coordinateView.drawableHotspotChanged(float, float)
protected void setStaticTransformationsEnabled(boolean enabled)
getChildStaticTransformation(View, android.view.animation.Transformation)
to be
invoked when a child is drawn.
Any subclass overriding
getChildStaticTransformation(View, android.view.animation.Transformation)
should
set this property to true.enabled
- True to enable static transformations on children, false otherwise.getChildStaticTransformation(View, android.view.animation.Transformation)
protected boolean getChildStaticTransformation(View child, Transformation t)
t
to be the static transformation of the child, if set, returning a
boolean to indicate whether a static transform was set. The default implementation
simply returns false
; subclasses may override this method for different
behavior. setStaticTransformationsEnabled(boolean)
must be set to true
for this method to be called.child
- The child view whose static transform is being requestedt
- The Transformation which will hold the resultsetStaticTransformationsEnabled(boolean)
protected View findViewTraversal(@IdRes int id)
findViewTraversal
in class View
id
- the id of the view to be foundprotected View findViewWithTagTraversal(Object tag)
findViewWithTagTraversal
in class View
tag
- the tag of the view to be foundprotected View findViewByPredicateTraversal(Predicate<View> predicate, View childToSkip)
findViewByPredicateTraversal
in class View
predicate
- The predicate to evaluate.childToSkip
- If not null, ignores this child during the recursive traversal.public void addTransientView(View view, int index)
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.
view
- The view to be addedindex
- The index at which this view should be drawn, must be >= 0.
This value is relative to the index
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.public void removeTransientView(View view)
view
- The transient view to be removedpublic int getTransientViewCount()
getTransientView(int)
and getTransientViewIndex(int)
.addTransientView(View, int)
public int getTransientViewIndex(int position)
position
- The position of the index being queried. Must be at least 0
and less than the value returned by getTransientViewCount()
.public View getTransientView(int position)
position
- The position of the view being queried. Must be at least 0
and less than the value returned by getTransientViewCount()
.public void addView(View child)
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(android.graphics.Canvas)
, View.onDraw(android.graphics.Canvas)
,
dispatchDraw(android.graphics.Canvas)
or any related method.
child
- the child view to addgenerateDefaultLayoutParams()
public void addView(View child, int index)
Note: do not invoke this method from
View.draw(android.graphics.Canvas)
, View.onDraw(android.graphics.Canvas)
,
dispatchDraw(android.graphics.Canvas)
or any related method.
child
- the child view to addindex
- the position at which to add the childgenerateDefaultLayoutParams()
public void addView(View child, int width, int height)
Note: do not invoke this method from
View.draw(android.graphics.Canvas)
, View.onDraw(android.graphics.Canvas)
,
dispatchDraw(android.graphics.Canvas)
or any related method.
child
- the child view to addpublic void addView(View child, ViewGroup.LayoutParams params)
Note: do not invoke this method from
View.draw(android.graphics.Canvas)
, View.onDraw(android.graphics.Canvas)
,
dispatchDraw(android.graphics.Canvas)
or any related method.
addView
in interface ViewManager
child
- the child view to addparams
- the layout parameters to set on the childpublic void addView(View child, int index, ViewGroup.LayoutParams params)
Note: do not invoke this method from
View.draw(android.graphics.Canvas)
, View.onDraw(android.graphics.Canvas)
,
dispatchDraw(android.graphics.Canvas)
or any related method.
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 childpublic void updateViewLayout(View view, ViewGroup.LayoutParams params)
updateViewLayout
in interface ViewManager
protected boolean checkLayoutParams(ViewGroup.LayoutParams p)
public void setOnHierarchyChangeListener(ViewGroup.OnHierarchyChangeListener listener)
listener
- the callback to invoke on hierarchy changepublic void onViewAdded(View child)
child
- the added child viewpublic void onViewRemoved(View child)
child
- the removed child viewprotected void onAttachedToWindow()
View
View.onDraw(android.graphics.Canvas)
,
however it may be called any time before the first onDraw -- including
before or after View.onMeasure(int, int)
.onAttachedToWindow
in class View
View.onDetachedFromWindow()
protected void onDetachedFromWindow()
View
onDetachedFromWindow
in class View
View.onAttachedToWindow()
protected boolean addViewInLayout(View child, int index, ViewGroup.LayoutParams params)
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 childprotected boolean addViewInLayout(View child, int index, ViewGroup.LayoutParams params, boolean preventRequestLayout)
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 childprotected void cleanupLayoutState(View child)
child
- the child on which to perform the cleanupprotected void attachLayoutAnimationParameters(View child, ViewGroup.LayoutParams params, int index, int count)
child
- the child to associate with animation parametersparams
- the child's layout parameters which hold the animation
parametersindex
- the index of the child in the view groupcount
- the number of children in the view grouppublic void removeView(View view)
Note: do not invoke this method from
View.draw(android.graphics.Canvas)
, View.onDraw(android.graphics.Canvas)
,
dispatchDraw(android.graphics.Canvas)
or any related method.
removeView
in interface ViewManager
public void removeViewInLayout(View view)
Note: do not invoke this method from
View.draw(android.graphics.Canvas)
, View.onDraw(android.graphics.Canvas)
,
dispatchDraw(android.graphics.Canvas)
or any related method.
view
- the view to remove from the grouppublic void removeViewsInLayout(int start, int count)
Note: do not invoke this method from
View.draw(android.graphics.Canvas)
, View.onDraw(android.graphics.Canvas)
,
dispatchDraw(android.graphics.Canvas)
or any related method.
start
- the index of the first view to remove from the groupcount
- the number of views to remove from the grouppublic void removeViewAt(int index)
Note: do not invoke this method from
View.draw(android.graphics.Canvas)
, View.onDraw(android.graphics.Canvas)
,
dispatchDraw(android.graphics.Canvas)
or any related method.
index
- the position in the group of the view to removepublic void removeViews(int start, int count)
Note: do not invoke this method from
View.draw(android.graphics.Canvas)
, View.onDraw(android.graphics.Canvas)
,
dispatchDraw(android.graphics.Canvas)
or any related method.
start
- the first position in the group of the range of views to removecount
- the number of views to removepublic void setLayoutTransition(LayoutTransition transition)
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.
transition
- The LayoutTransition object that will animated changes in layout. A value
of null
means no transition will run on layout changes.public LayoutTransition getLayoutTransition()
null
means no transition will run on layout changes.public void removeAllViews()
Note: do not invoke this method from
View.draw(android.graphics.Canvas)
, View.onDraw(android.graphics.Canvas)
,
dispatchDraw(android.graphics.Canvas)
or any related method.
public void removeAllViewsInLayout()
Note: do not invoke this method from
View.draw(android.graphics.Canvas)
, View.onDraw(android.graphics.Canvas)
,
dispatchDraw(android.graphics.Canvas)
or any related method.
protected void removeDetachedView(View child, boolean animate)
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()
or View.invalidate()
calls.
For example, callers can post
a Runnable
which performs a View.requestLayout()
on the next frame, after all detach/remove
calls are finished, causing layout to be run prior to redrawing the view hierarchy.
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 windowattachViewToParent(View, int, android.view.ViewGroup.LayoutParams)
,
detachAllViewsFromParent()
,
detachViewFromParent(View)
,
detachViewFromParent(int)
protected void attachViewToParent(View child, int index, ViewGroup.LayoutParams params)
getChildAt(int)
.
This method is intended to be lightweight and makes no assumptions about whether the
parent or child should be redrawn. Proper use of this method will include also making
any appropriate View.requestLayout()
or View.invalidate()
calls.
For example, callers can post
a Runnable
which performs a View.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.
child
- the child to attachindex
- the index at which the child should be attachedparams
- the layout parameters of the childremoveDetachedView(View, boolean)
,
detachAllViewsFromParent()
,
detachViewFromParent(View)
,
detachViewFromParent(int)
protected void detachViewFromParent(View child)
attachViewToParent(View, int, android.view.ViewGroup.LayoutParams)
or a call to removeDetachedView(View, boolean)
. Detachment should only be
temporary; reattachment or removal should happen within the same drawing cycle as
detachment. When a view is detached, its parent is null and cannot be retrieved by a
call to getChildAt(int)
.child
- the child to detachdetachViewFromParent(int)
,
detachViewsFromParent(int, int)
,
detachAllViewsFromParent()
,
attachViewToParent(View, int, android.view.ViewGroup.LayoutParams)
,
removeDetachedView(View, boolean)
protected void detachViewFromParent(int index)
attachViewToParent(View, int, android.view.ViewGroup.LayoutParams)
or a call to removeDetachedView(View, boolean)
. Detachment should only be
temporary; reattachment or removal should happen within the same drawing cycle as
detachment. When a view is detached, its parent is null and cannot be retrieved by a
call to getChildAt(int)
.index
- the index of the child to detachdetachViewFromParent(View)
,
detachAllViewsFromParent()
,
detachViewsFromParent(int, int)
,
attachViewToParent(View, int, android.view.ViewGroup.LayoutParams)
,
removeDetachedView(View, boolean)
protected void detachViewsFromParent(int start, int count)
attachViewToParent(View, int, android.view.ViewGroup.LayoutParams)
or a call to removeDetachedView(View, boolean)
. Detachment should only be
temporary; reattachment or removal should happen within the same drawing cycle as
detachment. When a view is detached, its parent is null and cannot be retrieved by a
call to getChildAt(int)
.start
- the first index of the childrend range to detachcount
- the number of children to detachdetachViewFromParent(View)
,
detachViewFromParent(int)
,
detachAllViewsFromParent()
,
attachViewToParent(View, int, android.view.ViewGroup.LayoutParams)
,
removeDetachedView(View, boolean)
protected void detachAllViewsFromParent()
attachViewToParent(View, int, android.view.ViewGroup.LayoutParams)
or a call to removeDetachedView(View, boolean)
. Detachment should only be
temporary; reattachment or removal should happen within the same drawing cycle as
detachment. When a view is detached, its parent is null and cannot be retrieved by a
call to getChildAt(int)
.public final void invalidateChild(View child, Rect dirty)
invalidateChild
in interface ViewParent
child
- The child which is dirtydirty
- The area within the child that is invalidpublic ViewParent invalidateChildInParent(int[] location, Rect dirty)
invalidateChildInParent
in interface ViewParent
location
- An array of 2 ints containing the left and top
coordinates of the child to invalidatedirty
- The area within the child that is invalidpublic boolean damageChildDeferred(View child)
public void damageChild(View child, Rect dirty)
protected ViewParent damageChildInParent(int left, int top, Rect dirty)
public final void offsetDescendantRectToMyCoords(View descendant, Rect rect)
descendant
- A descendant of this viewrect
- A rectangle defined in descendant's coordinate space.public final void offsetRectIntoDescendantCoords(View descendant, Rect rect)
descendant
- A descendant of this viewrect
- A rectangle defined in descendant's coordinate space.public void offsetChildrenTopAndBottom(int offset)
offset
- the number of pixels to offsetpublic boolean getChildVisibleRect(View child, Rect r, Point offset)
ViewParent
Returns the clipped visible part of the rectangle r
, defined in the
child
'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.
getChildVisibleRect
in interface ViewParent
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 the r
parameter, this will be overwritten to contain the global (root)
coordinates of that point.
A null
value is valid (in case you are not interested in this result)public boolean getChildVisibleRect(View child, Rect r, Point offset, boolean forceParentCheck)
forceParentCheck
- true to guarantee that this call will propagate to all ancestors,
false otherwisepublic final void layout(int l, int t, int r, int b)
View
This is the second phase of the layout mechanism. (The first is measuring). In this phase, each parent calls layout on all of its children to position them. This is typically done using the child measurements that were stored in the measure pass().
Derived classes should not override this method. Derived classes with children should override onLayout. In that method, they should call layout on each of their children.
protected abstract void onLayout(boolean changed, int l, int t, int r, int b)
View
protected boolean canAnimate()
public void startLayoutAnimation()
public void scheduleLayoutAnimation()
public void setLayoutAnimation(LayoutAnimationController controller)
controller
- the animation controllerpublic LayoutAnimationController getLayoutAnimation()
public boolean isAnimationCacheEnabled()
Build.VERSION_CODES.M
, this property is ignored.
Caching behavior of children may be controlled through View.setLayerType(int, Paint)
.setAnimationCacheEnabled(boolean)
,
View.setDrawingCacheEnabled(boolean)
public void setAnimationCacheEnabled(boolean enabled)
Build.VERSION_CODES.M
, this property is ignored.
Caching behavior of children may be controlled through View.setLayerType(int, Paint)
.enabled
- true to enable the animation cache, false otherwiseisAnimationCacheEnabled()
,
View.setDrawingCacheEnabled(boolean)
public boolean isAlwaysDrawnWithCacheEnabled()
Build.VERSION_CODES.M
, this property is ignored.
Child views may no longer have their caching behavior disabled by parents.setAlwaysDrawnWithCacheEnabled(boolean)
,
setChildrenDrawnWithCacheEnabled(boolean)
,
View.setDrawingCacheEnabled(boolean)
public void setAlwaysDrawnWithCacheEnabled(boolean always)
Build.VERSION_CODES.M
, this property is ignored.
Child views may no longer have their caching behavior disabled by parents.always
- true to always draw with the drawing cache, false otherwiseisAlwaysDrawnWithCacheEnabled()
,
setChildrenDrawnWithCacheEnabled(boolean)
,
View.setDrawingCacheEnabled(boolean)
,
View.setDrawingCacheQuality(int)
protected boolean isChildrenDrawnWithCacheEnabled()
Build.VERSION_CODES.M
, this property is ignored.
Child views may no longer be forced to cache their rendering state by their parents.
Use View.setLayerType(int, Paint)
on individual Views instead.setAlwaysDrawnWithCacheEnabled(boolean)
,
setChildrenDrawnWithCacheEnabled(boolean)
protected void setChildrenDrawnWithCacheEnabled(boolean enabled)
Build.VERSION_CODES.M
, this property is ignored.
Child views may no longer be forced to cache their rendering state by their parents.
Use View.setLayerType(int, Paint)
on individual Views instead.isAlwaysDrawnWithCacheEnabled()
is true. A child's drawing cache
will be used only if it has been enabled.
Subclasses should call this method to start and stop using the drawing cache when
they perform performance sensitive operations, like scrolling or animating.enabled
- true if children should be drawn with their cache, false otherwisesetAlwaysDrawnWithCacheEnabled(boolean)
,
isChildrenDrawnWithCacheEnabled()
protected boolean isChildrenDrawingOrderEnabled()
getChildDrawingOrder(int, int)
.getChildDrawingOrder(int, int)
,
false otherwisesetChildrenDrawingOrderEnabled(boolean)
,
getChildDrawingOrder(int, int)
protected void setChildrenDrawingOrderEnabled(boolean enabled)
getChildDrawingOrder(int, int)
.
Note that Z
reordering, done by dispatchDraw(Canvas)
,
will override custom child ordering done via this method.
enabled
- true if the order of the children when drawing is determined by
getChildDrawingOrder(int, int)
, false otherwiseisChildrenDrawingOrderEnabled()
,
getChildDrawingOrder(int, int)
public int getPersistentDrawingCache()
PERSISTENT_NO_CACHE
,
PERSISTENT_ANIMATION_CACHE
, PERSISTENT_SCROLLING_CACHE
and PERSISTENT_ALL_CACHES
setPersistentDrawingCache(int)
,
setAnimationCacheEnabled(boolean)
public void setPersistentDrawingCache(int drawingCacheToKeep)
drawingCacheToKeep
- one or a combination of PERSISTENT_NO_CACHE
,
PERSISTENT_ANIMATION_CACHE
, PERSISTENT_SCROLLING_CACHE
and PERSISTENT_ALL_CACHES
getPersistentDrawingCache()
,
setAnimationCacheEnabled(boolean)
public int getLayoutMode()
LAYOUT_MODE_CLIP_BOUNDS
or LAYOUT_MODE_OPTICAL_BOUNDS
.
If no layoutMode was explicitly set, either programmatically or in an XML resource,
the method returns the layoutMode of the view's parent ViewGroup if such a parent exists,
otherwise the method returns a default value of LAYOUT_MODE_CLIP_BOUNDS
.
setLayoutMode(int)
public void setLayoutMode(int layoutMode)
LAYOUT_MODE_CLIP_BOUNDS
or
LAYOUT_MODE_OPTICAL_BOUNDS
.layoutMode
- the layout mode to use during layout operationsgetLayoutMode()
public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs)
attrs
- the attributes to build the layout parameters fromViewGroup.LayoutParams
or one
of its descendantsprotected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)
checkLayoutParams(android.view.ViewGroup.LayoutParams)
, this method
is invoked. This method should return a new set of layout params suitable for
this ViewGroup, possibly by copying the appropriate attributes from the
specified set of layout params.p
- The layout parameters to convert into a suitable set of layout parameters
for this ViewGroup.ViewGroup.LayoutParams
or one
of its descendantsprotected ViewGroup.LayoutParams generateDefaultLayoutParams()
addView(View)
has no layout parameters
already set. If null is returned, an exception is thrown from addView.protected void debug(int depth)
View
View.VIEW_LOG_TAG
. Each line in the output is preceded with an
indentation defined by the depth
.public int indexOfChild(View child)
child
- the view for which to get the positionpublic int getChildCount()
public View getChildAt(int index)
index
- the position at which to get the view fromprotected void measureChildren(int widthMeasureSpec, int heightMeasureSpec)
widthMeasureSpec
- The width requirements for this viewheightMeasureSpec
- The height requirements for this viewprotected void measureChild(View child, int parentWidthMeasureSpec, int parentHeightMeasureSpec)
child
- The child to measureparentWidthMeasureSpec
- The width requirements for this viewparentHeightMeasureSpec
- The height requirements for this viewprotected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed)
child
- The child to measureparentWidthMeasureSpec
- The width requirements for this viewwidthUsed
- Extra space that has been used up by the parent
horizontally (possibly by other children of the parent)parentHeightMeasureSpec
- The height requirements for this viewheightUsed
- Extra space that has been used up by the parent
vertically (possibly by other children of the parent)public static int getChildMeasureSpec(int spec, int padding, int childDimension)
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
dimensionpublic void clearDisappearingChildren()
public void startViewTransition(View view)
Fragment
and LayoutTransition
to animate
the removal of views. A call to this method should always be accompanied by a later call
to endViewTransition(View)
, such as after an animation on the View has finished,
so that the View finally gets removed.view
- The View object to be kept visible even if it gets removed from its parent.public void endViewTransition(View view)
startViewTransition(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.public void suppressLayout(boolean suppress)
public boolean isLayoutSuppressed()
suppressLayout(boolean)
.public boolean gatherTransparentRegion(Region region)
View
gatherTransparentRegion
in class View
region
- The transparent region for this ViewAncestor (window).public void requestTransparentRegion(View child)
ViewParent
requestTransparentRegion
in interface ViewParent
child
- the view requesting the transparent region computationpublic WindowInsets dispatchApplyWindowInsets(WindowInsets insets)
View
This method should be called by clients wishing to apply insets corresponding to areas obscured by window decorations or overlays. This can include the status and navigation bars, action bars, input methods and more. New inset categories may be added in the future. The method returns the insets provided minus any that were applied by this view or its children.
Clients wishing to provide custom behavior should override the
View.onApplyWindowInsets(WindowInsets)
method or alternatively provide a
View.OnApplyWindowInsetsListener
via the
setOnApplyWindowInsetsListener
method.
This method replaces the older fitSystemWindows
method.
dispatchApplyWindowInsets
in class View
insets
- Insets to applypublic Animation.AnimationListener getLayoutAnimationListener()
Animation.AnimationListener
protected void drawableStateChanged()
View
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.
drawableStateChanged
in class View
Drawable.setState(int[])
public void jumpDrawablesToCurrentState()
View
Drawable.jumpToCurrentState()
on all Drawable objects associated with this view.
Also calls StateListAnimator.jumpToCurrentState()
if there is a StateListAnimator
attached to this view.
jumpDrawablesToCurrentState
in class View
protected int[] onCreateDrawableState(int extraSpace)
View
Drawable
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 use View.getDrawableState()
.onCreateDrawableState
in class View
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.Drawable
state of
the view.View.mergeDrawableStates(int[], int[])
public void setAddStatesFromChildren(boolean addsStates)
public boolean addStatesFromChildren()
public void childDrawableStateChanged(View child)
addStatesFromChildren()
is true, refreshes this group's
drawable state (to include the states from its children).childDrawableStateChanged
in interface ViewParent
child
- The child whose drawable state has changed.public void setLayoutAnimationListener(Animation.AnimationListener animationListener)
Animation.AnimationListener.onAnimationStart(Animation)
and
Animation.AnimationListener.onAnimationEnd(Animation)
are invoked.animationListener
- the layout animation listenerpublic void requestTransitionStart(LayoutTransition transition)
transition
- The LayoutTransition to be started on the next traversal.public boolean resolveRtlPropertiesIfNeeded()
View
resolveRtlPropertiesIfNeeded
in class View
public boolean resolveLayoutDirection()
View
resolveLayoutDirection
in class View
public boolean resolveTextDirection()
View
resolveTextDirection
in class View
public boolean resolveTextAlignment()
View
resolveTextAlignment
in class View
public void resolvePadding()
View
resolvePadding
in class View
protected void resolveDrawables()
View
View.onResolveDrawables(int)
when resolution is done.resolveDrawables
in class View
public void resolveLayoutParams()
View
resolveLayoutParams
in class View
public void resetResolvedLayoutDirection()
View
View.onMeasure(int, int)
.resetResolvedLayoutDirection
in class View
public void resetResolvedTextDirection()
View
View.onMeasure(int, int)
.resetResolvedTextDirection
in class View
public void resetResolvedTextAlignment()
View
View.onMeasure(int, int)
.resetResolvedTextAlignment
in class View
public void resetResolvedPadding()
View
resetResolvedPadding
in class View
protected void resetResolvedDrawables()
resetResolvedDrawables
in class View
public boolean shouldDelayChildPressedState()
public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes)
ViewParent
This method will be called in response to a descendant view invoking
View.startNestedScroll(int)
. Each parent up the view hierarchy will be
given an opportunity to respond and claim the nested scrolling operation by returning
true
.
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)
.
onStartNestedScroll
in interface ViewParent
child
- Direct child of this ViewParent containing targettarget
- View that initiated the nested scrollnestedScrollAxes
- Flags consisting of View.SCROLL_AXIS_HORIZONTAL
,
View.SCROLL_AXIS_VERTICAL
or bothpublic void onNestedScrollAccepted(View child, View target, int axes)
ViewParent
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 superclass's
implementation of this method if one is present.
onNestedScrollAccepted
in interface ViewParent
child
- Direct child of this ViewParent containing targettarget
- View that initiated the nested scrollaxes
- Flags consisting of View.SCROLL_AXIS_HORIZONTAL
,
View.SCROLL_AXIS_VERTICAL
or bothViewParent.onStartNestedScroll(View, View, int)
,
ViewParent.onStopNestedScroll(View)
public void onStopNestedScroll(View child)
ViewParent
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
or MotionEvent.ACTION_CANCEL
event.
Implementations of this method should always call their superclass's implementation of this
method if one is present.
onStopNestedScroll
in interface ViewParent
child
- View that initiated the nested scrollpublic void onNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed)
ViewParent
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 to
ViewParent.onStartNestedScroll(View, View, 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.
onNestedScroll
in interface ViewParent
target
- The descendent 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 targetpublic void onNestedPreScroll(View target, int dx, int dy, int[] consumed)
ViewParent
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 invokes
View.dispatchNestedPreScroll(int, int, int[], int[])
. The implementation should
report how any pixels of the scroll reported by dx, dy were consumed in the
consumed
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.
onNestedPreScroll
in interface ViewParent
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 parentpublic boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed)
ViewParent
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
the minimum 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.
onNestedFling
in interface ViewParent
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 otherwisepublic boolean onNestedPreFling(View target, float velocityX, float velocityY)
ViewParent
This method siginfies 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
the minimum 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 returning
true
from this method, the parent indicates that the child should not
fling its own internal content as well.
onNestedPreFling
in interface ViewParent
target
- View that initiated the nested scrollvelocityX
- Horizontal velocity in pixels per secondvelocityY
- Vertical velocity in pixels per secondpublic int getNestedScrollAxes()
A ViewGroup 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.
View.SCROLL_AXIS_HORIZONTAL
,
View.SCROLL_AXIS_VERTICAL
,
View.SCROLL_AXIS_NONE
protected void onSetLayoutParams(View child, ViewGroup.LayoutParams layoutParams)
public void captureTransitioningViews(List<View> transitioningViews)
View
captureTransitioningViews
in class View
transitioningViews
- This View will be added to transitioningViews if it is VISIBLE and
a normal View or a ViewGroup with
isTransitionGroup()
true.public void findNamedViews(Map<String,View> namedElements)
View
View.getTransitionName()
non-null to namedElements.findNamedViews
in class View
namedElements
- Will contain all Views in the hierarchy having a transitionName.protected void encodeProperties(ViewHierarchyEncoder encoder)
View
encodeProperties
in class View