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.
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.MeasureSpec, View.OnAttachStateChangeListener, View.OnClickListener, View.OnCreateContextMenuListener, View.OnDragListener, View.OnFocusChangeListener, View.OnGenericMotionListener, View.OnHoverListener, View.OnKeyListener, View.OnLayoutChangeListener, View.OnLongClickListener, View.OnSystemUiVisibilityChangeListener, View.OnTouchListener
Modifier and Type | Field and Description |
---|---|
static int |
CLIP_BOUNDS
This constant is a
layoutMode . |
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.
|
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.
|
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 |
OPTICAL_BOUNDS
This constant is a
layoutMode . |
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.
|
ALPHA, DEBUG_LAYOUT_PROPERTY, DRAG_FLAG_GLOBAL, 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_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, mBottom, mCachingFailed, mContext, mCurrentAnimation, 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, 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, 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, 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_VISIBLE, SYSTEM_UI_CLEARABLE_FLAGS, SYSTEM_UI_FLAG_FULLSCREEN, SYSTEM_UI_FLAG_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_STABLE, SYSTEM_UI_FLAG_LOW_PROFILE, SYSTEM_UI_FLAG_VISIBLE, SYSTEM_UI_LAYOUT_FLAGS, 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_INHERIT, TEXT_DIRECTION_LOCALE, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, TRANSLATION_X, TRANSLATION_Y, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y
Constructor and Description |
---|
ViewGroup(Context context) |
ViewGroup(Context context,
AttributeSet attrs) |
ViewGroup(Context context,
AttributeSet attrs,
int defStyle) |
Modifier and Type | Method and Description |
---|---|
void |
addChildrenForAccessibility(ArrayList<View> childrenForAccessibility)
Adds the children of a given View for accessibility.
|
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 |
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
|
protected boolean |
canAnimate()
Indicates whether the view group has the ability to animate its children
after the first layout.
|
protected boolean |
checkLayoutParams(ViewGroup.LayoutParams p) |
void |
childAccessibilityStateChanged(View child)
A child notifies its parent that its state for accessibility has changed.
|
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.
|
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.
|
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 |
dispatchFinishTemporaryDetach() |
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.
|
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() |
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.
|
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.
|
protected View |
findViewByPredicateTraversal(com.android.internal.util.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) |
protected boolean |
fitSystemWindows(Rect insets)
Called by the view hierarchy when the content insets for a window have
changed, to allow it to adjust its content to fit within those windows.
|
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.
|
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.
|
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 view group:
either
CLIP_BOUNDS or OPTICAL_BOUNDS . |
LayoutTransition |
getLayoutTransition()
Gets the LayoutTransition object for this ViewGroup.
|
int |
getPersistentDrawingCache()
Returns an integer indicating what types of drawing caches are kept in memory.
|
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.
|
void |
invalidateChildFast(View child,
Rect dirty)
Quick invalidation method called by View.invalidateViewProperty.
|
ViewParent |
invalidateChildInParent(int[] location,
Rect dirty)
Don't call or override this method.
|
boolean |
isAlwaysDrawnWithCacheEnabled()
Indicates whether this ViewGroup will always try to draw its children using their
drawing cache.
|
boolean |
isAnimationCacheEnabled()
Indicates whether the children's drawing cache is used during a layout
animation.
|
protected boolean |
isChildrenDrawingOrderEnabled()
Indicates whether the ViewGroup is drawing its children in the order defined by
getChildDrawingOrder(int, int) . |
protected boolean |
isChildrenDrawnWithCacheEnabled()
Indicates whether the ViewGroup is currently drawing its children using
their drawing cache.
|
boolean |
isMotionEventSplittingEnabled()
Returns true if MotionEvents dispatched to this ViewGroup can be split to multiple children.
|
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.
|
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
|
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 |
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 |
onAnimationEnd()
Invoked by a parent ViewGroup to notify the end of the animation
currently associated with this view.
|
protected void |
onAnimationStart()
Invoked by a parent ViewGroup to notify the start of the animation
currently associated with this view.
|
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) |
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.
|
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. |
protected void |
onSetLayoutParams(View child,
ViewGroup.LayoutParams layoutParams) |
protected void |
onViewAdded(View child) |
protected void |
onViewRemoved(View child) |
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 |
removeView(View view) |
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.
|
void |
resetAccessibilityStateChanged()
Reset the state indicating the this view has requested clients
interested in its accessibility state to be notified.
|
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.
|
void |
resetRtlProperties()
Reset resolution of all RTL related properties.
|
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()
Resolve padding depending on layout direction.
|
void |
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)
Indicates whether this ViewGroup will always try to draw its children using their
drawing cache.
|
void |
setAnimationCacheEnabled(boolean enabled)
Enables or disables the children's drawing cache during a layout animation.
|
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)
Tells the ViewGroup to draw its children using their drawing cache.
|
void |
setClipChildren(boolean clipChildren)
By default, children are clipped to their bounds before drawing.
|
void |
setClipToPadding(boolean clipToPadding)
By default, children are clipped to the padding of the ViewGroup.
|
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 view group.
|
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. |
boolean |
shouldDelayChildPressedState()
Return true if the pressed state should be delayed for children or descendants of this
ViewGroup.
|
boolean |
showContextMenuForChild(View originalView)
Bring up a context menu for the specified view or its ancestors.
|
ActionMode |
startActionModeForChild(View originalView,
ActionMode.Callback callback)
Start an action mode 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 |
updateViewLayout(View view,
ViewGroup.LayoutParams params) |
addFocusables, addOnAttachStateChangeListener, addOnLayoutChangeListener, animate, announceForAccessibility, applyDrawableToTransparentRegion, awakenScrollBars, awakenScrollBars, awakenScrollBars, bringToFront, buildDrawingCache, buildDrawingCache, buildLayer, callOnClick, cancelLongPress, canHaveDisplayList, canResolveLayoutDirection, canScrollHorizontally, canScrollVertically, checkInputConnectionProxy, clearAccessibilityFocus, clearAnimation, combineMeasuredStates, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeOpaqueFlags, computeScroll, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createAccessibilityNodeInfo, createContextMenu, debug, debugIndent, destroyDrawingCache, destroyHardwareResources, dispatchGenericMotionEvent, dispatchPointerEvent, dispatchPopulateAccessibilityEvent, draw, findViewById, findViewByPredicate, findViewByPredicateInsideOut, findViewWithTag, fitsSystemWindows, focusSearch, forceLayout, generateViewId, getAccessibilityCursorPosition, getAccessibilityDelegate, getAccessibilityNodeProvider, getAccessibilityViewId, getAccessibilityWindowId, getAlpha, getAnimation, getApplicationWindowToken, getBackground, getBaseline, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getCameraDistance, getContentDescription, getContext, getContextMenuInfo, getDefaultSize, getDisplay, getDisplayList, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFadeHeight, getFadeTop, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusables, getFocusedRect, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHardwareRenderer, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getHorizontalScrollFactor, getId, getImportantForAccessibility, getIterableTextForAccessibility, getIteratorForGranularity, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOpticalInsets, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getRawLayoutDirection, getRawTextAlignment, getRawTextDirection, getResources, getRight, getRightFadingEdgeStrength, getRightPaddingOffset, getRootView, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollX, getScrollY, getSolidColor, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getSystemUiVisibility, getTag, getTag, getTextAlignment, getTextDirection, getTop, getTopFadingEdgeStrength, getTopPaddingOffset, getTouchables, getTouchDelegate, getTranslationX, getTranslationY, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarWidth, getVerticalScrollFactor, getViewRootImpl, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, hackTurnOffWindowResizeAnim, hasOnClickListeners, hasOpaqueScrollbars, hasOverlappingRendering, hasWindowFocus, includeForAccessibility, inflate, initializeFadingEdge, initializeScrollbars, invalidate, invalidate, invalidate, invalidateDrawable, invalidateParentCaches, invalidateParentIfNeeded, isActionableForAccessibility, isActivated, isClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isInEditMode, isInScrollingContainer, isInTouchMode, isLayoutDirectionInherited, isLayoutRequested, isLayoutRtl, isLongClickable, isOpaque, isPaddingOffsetRequired, isPaddingRelative, isPressed, isRootNamespace, isSaveEnabled, isSaveFromParentEnabled, isScrollbarFadingEnabled, isScrollContainer, isSelected, isShown, isSoundEffectsEnabled, isTextAlignmentInherited, isTextDirectionInherited, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVerticalScrollBarHidden, isVisibleToUser, isVisibleToUser, measure, mergeDrawableStates, notifyAccessibilityStateChanged, offsetLeftAndRight, offsetTopAndBottom, onAttachedToWindow, onCheckIsTextEditor, onCloseSystemDialogs, onConfigurationChanged, onCreateContextMenu, onCreateInputConnection, onDetachedFromWindow, onDisplayHint, onDragEvent, onDraw, onDrawHorizontalScrollBar, onDrawScrollBars, onDrawVerticalScrollBar, onFilterTouchEventForSecurity, onFinishInflate, onFinishTemporaryDetach, onFocusChanged, onFocusLost, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onMeasure, onOverScrolled, onPopulateAccessibilityEvent, onResolveDrawables, onRestoreInstanceState, onRtlPropertiesChanged, onSaveInstanceState, onScreenStateChanged, onScrollChanged, onSetAlpha, onSizeChanged, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onVisibilityChanged, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, onWindowVisibilityChanged, outputDirtyFlags, overScrollBy, performAccessibilityAction, performButtonActionOnTouchDown, performClick, performHapticFeedback, performHapticFeedback, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, postInvalidateOnAnimation, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, recomputePadding, refreshDrawableState, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestAccessibilityFocus, requestFitSystemWindows, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, resetPaddingToInitialValues, resolveSize, resolveSizeAndState, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAccessibilityCursorPosition, setAccessibilityDelegate, setActivated, setAlpha, setAnimation, setBackground, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBottom, setCameraDistance, setClickable, setContentDescription, setDisabledSystemUiVisibility, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusableInTouchMode, setFrame, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHovered, setId, setImportantForAccessibility, setIsRootNamespace, setKeepScreenOn, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutInsets, setLayoutParams, setLeft, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPressed, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollContainer, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setSystemUiVisibility, setTag, setTag, setTagInternal, setTextAlignment, setTextDirection, setTop, setTouchDelegate, setTranslationX, setTranslationY, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, showContextMenu, showContextMenu, startActionMode, startAnimation, startDrag, toString, unscheduleDrawable, unscheduleDrawable, verifyDrawable, willNotCacheDrawing, willNotDraw
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createContextMenu, getParent, getParentForAccessibility, isLayoutRequested, requestFitSystemWindows, requestLayout
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 CLIP_BOUNDS
public static final int 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.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 defStyle)
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)
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)
focusableViewAvailable
in interface ViewParent
v
- The view that has become newly focusablepublic boolean showContextMenuForChild(View originalView)
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 invokedpublic ActionMode startActionModeForChild(View originalView, ActionMode.Callback callback)
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 modepublic 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)
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)
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 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)
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)
clearChildFocus
in interface ViewParent
child
- The view that is giving up focuspublic void clearFocus()
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 wich 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.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
public void addFocusables(ArrayList<View> views, int direction, int focusableMode)
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 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 void dispatchWindowFocusChanged(boolean hasFocus)
dispatchWindowFocusChanged
in class View
hasFocus
- True if the window containing this view now has focus,
false otherwise.public void addTouchables(ArrayList<View> views)
addTouchables
in class View
views
- Touchable views found so farpublic void makeOptionalFitsSystemWindows()
View
makeOptionalFitsSystemWindows
in class View
public void dispatchDisplayHint(int hint)
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)
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)
dispatchWindowVisibilityChanged
in class View
visibility
- The new visibility of the window.View.onWindowVisibilityChanged(int)
public void dispatchConfigurationChanged(Configuration newConfig)
dispatchConfigurationChanged
in class View
newConfig
- The new resource configuration.View.onConfigurationChanged(android.content.res.Configuration)
public void recomputeViewAttributes(View child)
recomputeViewAttributes
in interface ViewParent
child
- View whose attributes have changed.public void bringChildToFront(View child)
bringChildToFront
in interface ViewParent
public boolean dispatchDragEvent(DragEvent event)
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)
dispatchKeyEventPreIme
in class View
event
- The key event to be dispatched.public boolean dispatchKeyEvent(KeyEvent event)
dispatchKeyEvent
in class View
event
- The key event to be dispatched.public boolean dispatchKeyShortcutEvent(KeyEvent event)
dispatchKeyShortcutEvent
in class View
event
- The key event to be dispatched.public boolean dispatchTrackballEvent(MotionEvent event)
dispatchTrackballEvent
in class View
event
- The motion event to be dispatched.protected boolean dispatchHoverEvent(MotionEvent event)
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> childrenForAccessibility)
View
addChildrenForAccessibility
in class View
childrenForAccessibility
- The list of children for accessibility.public void childAccessibilityStateChanged(View child)
ViewParent
childAccessibilityStateChanged
in interface ViewParent
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 always returns false.
event
- The motion event that describes the hover.protected boolean dispatchGenericPointerEvent(MotionEvent event)
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)
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)
dispatchTouchEvent
in class View
ev
- The motion event to be dispatched.protected boolean isTransformedTouchPointInView(float x, float y, View child, PointF outLocalPoint)
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 void requestDisallowInterceptTouchEvent(boolean disallowIntercept)
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()
dispatchStartTemporaryDetach
in class View
public void dispatchFinishTemporaryDetach()
dispatchFinishTemporaryDetach
in class View
public void resetAccessibilityStateChanged()
View
resetAccessibilityStateChanged
in class View
protected void internalSetPadding(int left, int top, int right, int bottom)
internalSetPadding
in class View
protected void dispatchSaveInstanceState(SparseArray<Parcelable> container)
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.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 itprotected void onAnimationStart()
View
onAnimationStart
in class View
View.setAnimation(android.view.animation.Animation)
,
View.getAnimation()
protected void onAnimationEnd()
View
onAnimationEnd
in class View
View.setAnimation(android.view.animation.Animation)
,
View.getAnimation()
protected void onDebugDrawMargins(Canvas canvas)
protected void onDebugDraw(Canvas canvas)
protected void dispatchDraw(Canvas canvas)
dispatchDraw
in class View
canvas
- the canvas on which to draw the viewprotected 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 void setClipChildren(boolean clipChildren)
clipChildren
- true to clip children to their bounds,
false otherwisepublic void setClipToPadding(boolean clipToPadding)
clipToPadding
- true to clip children to the padding of the
group, false otherwisepublic void dispatchSetSelected(boolean selected)
dispatchSetSelected
in class View
selected
- The new selected stateView.setSelected(boolean)
public void dispatchSetActivated(boolean activated)
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)
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(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(com.android.internal.util.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 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 childparams
- 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 changeprotected void onViewAdded(View child)
protected void onViewRemoved(View child)
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 addedparams
- 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 addedparams
- 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)
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 void invalidateChildFast(View child, 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)
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 final void layout(int l, int t, int r, int b)
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)
protected boolean canAnimate()
public void startLayoutAnimation()
public void scheduleLayoutAnimation()
public void setLayoutAnimation(LayoutAnimationController controller)
controller
- the animation controllerpublic LayoutAnimationController getLayoutAnimation()
public boolean isAnimationCacheEnabled()
setAnimationCacheEnabled(boolean)
,
View.setDrawingCacheEnabled(boolean)
public void setAnimationCacheEnabled(boolean enabled)
enabled
- true to enable the animation cache, false otherwiseisAnimationCacheEnabled()
,
View.setDrawingCacheEnabled(boolean)
public boolean isAlwaysDrawnWithCacheEnabled()
setAlwaysDrawnWithCacheEnabled(boolean)
,
setChildrenDrawnWithCacheEnabled(boolean)
,
View.setDrawingCacheEnabled(boolean)
public void setAlwaysDrawnWithCacheEnabled(boolean always)
always
- true to always draw with the drawing cache, false otherwiseisAlwaysDrawnWithCacheEnabled()
,
setChildrenDrawnWithCacheEnabled(boolean)
,
View.setDrawingCacheEnabled(boolean)
,
View.setDrawingCacheQuality(int)
protected boolean isChildrenDrawnWithCacheEnabled()
setAlwaysDrawnWithCacheEnabled(boolean)
,
setChildrenDrawnWithCacheEnabled(boolean)
protected void setChildrenDrawnWithCacheEnabled(boolean enabled)
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)
.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()
CLIP_BOUNDS
or OPTICAL_BOUNDS
.setLayoutMode(int)
public void setLayoutMode(int layoutMode)
CLIP_BOUNDS
or OPTICAL_BOUNDS
.
The default is CLIP_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_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 boolean gatherTransparentRegion(Region region)
gatherTransparentRegion
in class View
region
- The transparent region for this ViewAncestor (window).public void requestTransparentRegion(View child)
requestTransparentRegion
in interface ViewParent
child
- the view requesting the transparent region computationprotected boolean fitSystemWindows(Rect insets)
View
You do not normally need to deal with this function, since the default
window decoration given to applications takes care of applying it to the
content of the window. If you use View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
this will not be the case,
and your content can be placed under those system elements. You can then
use this method within your view hierarchy if you have parts of your UI
which you would like to ensure are not being covered.
The default implementation of this method simply applies the content
inset's to the view's padding, consuming that content (modifying the
insets to be 0), and returning true. This behavior is off by default, but can
be enabled through View.setFitsSystemWindows(boolean)
.
This function's traversal down the hierarchy is depth-first. The same content insets object is propagated down the hierarchy, so any changes made to it will be seen by all following views (including potentially ones above in the hierarchy since this is a depth-first traversal). The first view that returns true will abort the entire traversal.
The default implementation works well for a situation where it is used with a container that covers the entire window, allowing it to apply the appropriate insets to its content on all edges. If you need a more complicated layout (such as two different views fitting system windows, one on the top of the window, and one on the bottom), you can override the method and handle the insets however you would like. Note that the insets provided by the framework are always relative to the far edges of the window, not accounting for the location of the called view within that window. (In fact when this method is called you do not yet know where the layout will place the view, as it is done before layout happens.)
Note: unlike many View methods, there is no dispatch phase to this call. If you are overriding it in a ViewGroup and want to allow the call to continue to your children, you must be sure to call the super implementation.
Here is a sample layout that makes use of fitting system windows
to have controls for a video view placed inside of the window decorations
that it hides and shows. This can be used with code like the second
sample (video player) shown in View.setSystemUiVisibility(int)
.
fitSystemWindows
in class View
insets
- Current content insets of the window. Prior to
Build.VERSION_CODES.JELLY_BEAN
you must not modify
the insets or else you and Android will be unhappy.View.getFitsSystemWindows()
,
View.setFitsSystemWindows(boolean)
,
View.setSystemUiVisibility(int)
public Animation.AnimationListener getLayoutAnimationListener()
Animation.AnimationListener
protected void drawableStateChanged()
View
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.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 void 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 resetRtlProperties()
View
resetRtlProperties
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()
protected void onSetLayoutParams(View child, ViewGroup.LayoutParams layoutParams)