public abstract class

ViewGroup

extends View
implements ViewManager ViewParent
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

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.

Developer Guides

For more information about creating user interface layouts, read the XML Layouts developer guide.

Summary

Nested Classes
class ViewGroup.LayoutParams LayoutParams are used by views to tell their parents how they want to be laid out. 
class ViewGroup.MarginLayoutParams Per-child layout information for layouts that support margins. 
interface ViewGroup.OnHierarchyChangeListener Interface definition for a callback to be invoked when the hierarchy within this view changed. 
XML Attributes
Attribute Name Related Method Description
android:addStatesFromChildren Sets whether this ViewGroup's drawable states also include its children's drawable states. 
android:alwaysDrawnWithCache Defines whether the ViewGroup should always draw its children using their drawing cache or not. 
android:animateLayoutChanges setLayoutTransition(LayoutTransition) Defines whether changes in layout (caused by adding and removing items) should cause a LayoutTransition to run. 
android:animationCache Defines whether layout animations should create a drawing cache for their children. 
android:clipChildren setClipChildren(boolean) Defines whether a child is limited to draw inside of its bounds or not. 
android:clipToPadding setClipToPadding(boolean) Defines whether the ViewGroup will clip its drawing surface so as to exclude the padding area. 
android:descendantFocusability Defines the relationship between the ViewGroup and its descendants when looking for a View to take focus. 
android:layoutAnimation Defines the layout animation to use the first time the ViewGroup is laid out. 
android:persistentDrawingCache Defines the persistence of the drawing cache. 
[Expand]
Inherited XML Attributes
From class android.view.View
Constants
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.
int FOCUS_AFTER_DESCENDANTS This view will get focus only if none of its descendants want it.
int FOCUS_BEFORE_DESCENDANTS This view will get focus before any of its descendants.
int FOCUS_BLOCK_DESCENDANTS This view will block any of its descendants from getting focus, even if they are focusable.
int PERSISTENT_ALL_CACHES Used to indicate that all drawing caches should be kept in memory.
int PERSISTENT_ANIMATION_CACHE Used to indicate that the animation drawing cache should be kept in memory.
int PERSISTENT_NO_CACHE Used to indicate that no drawing cache should be kept in memory.
int PERSISTENT_SCROLLING_CACHE Used to indicate that the scrolling drawing cache should be kept in memory.
[Expand]
Inherited Constants
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
ViewGroup(Context context)
ViewGroup(Context context, AttributeSet attrs)
ViewGroup(Context context, AttributeSet attrs, int defStyle)
Public Methods
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.
void addFocusables(ArrayList<View> views, int direction)
Add 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, 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.
void addView(View child, int index)
Adds a child view.
void addView(View child)
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 bringChildToFront(View child)
Change the z order of the child so it's on top of all other children
void childDrawableStateChanged(View child)
If {link #addStatesFromChildren} is true, refreshes this group's drawable state (to include the states from its children).
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.
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. !!! TODO: write real docs
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.
void dispatchSetActivated(boolean activated)
Dispatch setActivated to all of this View's children.
void dispatchSetSelected(boolean selected)
Dispatch setSelected to all of this View's children.
void dispatchSystemUiVisibilityChanged(int visible)
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.
void dispatchWindowFocusChanged(boolean hasFocus)
Called when the window containing this view gains or loses window focus.
void dispatchWindowVisibilityChanged(int visibility)
Dispatch a window visibility change down the view hierarchy.
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 findViewsWithText(ArrayList<View> outViews, CharSequence text, int flags)
Finds the Views that contain given text.
View focusSearch(View focused, int direction)
Find the nearest view in the specified direction that wants to take focus.
void focusableViewAvailable(View v)
Tells the parent that a new focusable view has become available.
boolean gatherTransparentRegion(Region region)
This is used by the RootView to perform an optimization when the view hierarchy contains one or several SurfaceView.
ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs)
Returns a new set of layout parameters based on the supplied attributes set.
View getChildAt(int index)
Returns the view at the specified position in the group.
int getChildCount()
Returns the number of children in the group.
static int getChildMeasureSpec(int spec, int padding, int childDimension)
Does the hard part of measureChildren: figuring out the MeasureSpec to pass to a particular child.
boolean getChildVisibleRect(View child, Rect r, Point offset)
Compute the visible part of a rectangular region defined in terms of a child view's coordinates.
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.
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 hasFocusable() returns true.
int indexOfChild(View child)
Returns the position in the group of the specified child view.
final 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()
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.
boolean isMotionEventSplittingEnabled()
Returns true if MotionEvents dispatched to this ViewGroup can be split to multiple children.
void jumpDrawablesToCurrentState()
Call Drawable.jumpToCurrentState() on all Drawable objects associated with this view.
final 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.

final void offsetDescendantRectToMyCoords(View descendant, Rect rect)
Offset a rectangle that is in a descendant's coordinate space into our coordinate space.
final void offsetRectIntoDescendantCoords(View descendant, Rect rect)
Offset a rectangle that is in our coordinate space into an ancestor's coordinate space.
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.
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.
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.
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. Looks for a view to give focus to respecting the setting specified by getDescendantFocusability().
boolean requestSendAccessibilityEvent(View child, AccessibilityEvent event)
Called by a child to request from its parent to send an AccessibilityEvent.
void requestTransparentRegion(View child)
Called when a child wants the view hierarchy to gather and report transparent regions to the window compositor.
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.
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 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 setPadding(int left, int top, int right, int bottom)
Sets the padding.
void setPersistentDrawingCache(int drawingCacheToKeep)
Indicates what types of drawing caches should be kept in memory after they have been created.
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)
Protected Methods
boolean addViewInLayout(View child, int index, ViewGroup.LayoutParams params, boolean preventRequestLayout)
Adds a view during layout.
boolean addViewInLayout(View child, int index, ViewGroup.LayoutParams params)
Adds a view during layout.
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.
void attachViewToParent(View child, int index, ViewGroup.LayoutParams params)
Attaches a view to this view group.
boolean canAnimate()
Indicates whether the view group has the ability to animate its children after the first layout.
boolean checkLayoutParams(ViewGroup.LayoutParams p)
void cleanupLayoutState(View child)
Prevents the specified child to be laid out during the next layout pass.
void debug(int depth)
Prints information about this view in the log output, with the tag VIEW_LOG_TAG.
void detachAllViewsFromParent()
Detaches all views from the parent.
void detachViewFromParent(View child)
Detaches a view from its parent.
void detachViewFromParent(int index)
Detaches a view from its parent.
void detachViewsFromParent(int start, int count)
Detaches a range of view from their parent.
void dispatchDraw(Canvas canvas)
Called by draw to draw the child views.
void dispatchFreezeSelfOnly(SparseArray<Parcelable> container)
Perform dispatching of a saveHierarchyState(android.util.SparseArray) freeze()} to only this view, not to its children.
boolean dispatchGenericFocusedEvent(MotionEvent event)
Dispatch a generic motion event to the currently focused view.
boolean dispatchGenericPointerEvent(MotionEvent event)
Dispatch a generic motion event to the view under the first pointer.
boolean dispatchHoverEvent(MotionEvent event)
Dispatch a hover event.
void dispatchRestoreInstanceState(SparseArray<Parcelable> container)
Called by restoreHierarchyState(android.util.SparseArray) to retrieve the state for this view and its children.
void dispatchSaveInstanceState(SparseArray<Parcelable> container)
Called by saveHierarchyState(android.util.SparseArray) to store the state for this view and its children.
void dispatchSetPressed(boolean pressed)
Dispatch setPressed to all of this View's children.
void dispatchThawSelfOnly(SparseArray<Parcelable> container)
Perform dispatching of a restoreHierarchyState(android.util.SparseArray) to only this view, not to its children.
void dispatchVisibilityChanged(View changedView, int visibility)
Dispatch a view visibility change down the view hierarchy.
boolean drawChild(Canvas canvas, View child, long drawingTime)
Draw one child of this View Group.
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.
boolean fitSystemWindows(Rect insets)
Apply the insets for system windows to this view, if the FITS_SYSTEM_WINDOWS flag is set
ViewGroup.LayoutParams generateDefaultLayoutParams()
Returns a set of default layout parameters.
ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)
Returns a safe set of layout parameters based on the supplied layout params.
int getChildDrawingOrder(int childCount, int i)
Returns the index of the child to draw for this iteration.
boolean getChildStaticTransformation(View child, Transformation t)
boolean isChildrenDrawingOrderEnabled()
Indicates whether the ViewGroup is drawing its children in the order defined by getChildDrawingOrder(int, int).
boolean isChildrenDrawnWithCacheEnabled()
Indicates whether the ViewGroup is currently drawing its children using their drawing cache.
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.
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 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.
void onAnimationEnd()
Invoked by a parent ViewGroup to notify the end of the animation currently associated with this view.
void onAnimationStart()
Invoked by a parent ViewGroup to notify the start of the animation currently associated with this view.
int[] onCreateDrawableState(int extraSpace)
Generate the new Drawable state for this view.
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 onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect)
Look for a descendant to call requestFocus() on.
void removeDetachedView(View child, boolean animate)
Finishes the removal of a detached view.
void resetResolvedLayoutDirection()
Reset the resolved layout direction.
void resetResolvedTextDirection()
Reset resolved text direction.
void setChildrenDrawingCacheEnabled(boolean enabled)
Enables or disables the drawing cache for each child of this view group.
void setChildrenDrawingOrderEnabled(boolean enabled)
Tells the ViewGroup whether to draw its children in the order defined by the method getChildDrawingOrder(int, int).
void setChildrenDrawnWithCacheEnabled(boolean enabled)
Tells the ViewGroup to draw its children using their drawing cache.
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.
[Expand]
Inherited Methods
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource

XML Attributes

android:addStatesFromChildren

Sets whether this ViewGroup's drawable states also include its children's drawable states. This is used, for example, to make a group appear to be focused when its child EditText or button is focused.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol addStatesFromChildren.

Related Methods

android:alwaysDrawnWithCache

Defines whether the ViewGroup should always draw its children using their drawing cache or not. The default value is true.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol alwaysDrawnWithCache.

Related Methods

android:animateLayoutChanges

Defines whether changes in layout (caused by adding and removing items) should cause a LayoutTransition to run. When this flag is set to true, a default LayoutTransition object will be set on the ViewGroup container and default animations will run when these layout changes occur.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol animateLayoutChanges.

android:animationCache

Defines whether layout animations should create a drawing cache for their children. Enabling the animation cache consumes more memory and requires a longer initialization but provides better performance. The animation cache is enabled by default.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol animationCache.

Related Methods

android:clipChildren

Defines whether a child is limited to draw inside of its bounds or not. This is useful with animations that scale the size of the children to more than 100% for instance. In such a case, this property should be set to false to allow the children to draw outside of their bounds. The default value of this property is true.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol clipChildren.

Related Methods

android:clipToPadding

Defines whether the ViewGroup will clip its drawing surface so as to exclude the padding area. This property is set to true by default.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol clipToPadding.

Related Methods

android:descendantFocusability

Defines the relationship between the ViewGroup and its descendants when looking for a View to take focus.

Must be one of the following constant values.

ConstantValueDescription
beforeDescendants0 The ViewGroup will get focus before any of its descendants.
afterDescendants1 The ViewGroup will get focus only if none of its descendants want it.
blocksDescendants2 The ViewGroup will block its descendants from receiving focus.

This corresponds to the global attribute resource symbol descendantFocusability.

Related Methods

android:layoutAnimation

Defines the layout animation to use the first time the ViewGroup is laid out. Layout animations can also be started manually after the first layout.

Must be a reference to another resource, in the form "@[+][package:]type:name" or to a theme attribute in the form "?[package:][type:]name".

This corresponds to the global attribute resource symbol layoutAnimation.

Related Methods

android:persistentDrawingCache

Defines the persistence of the drawing cache. The drawing cache might be enabled by a ViewGroup for all its children in specific situations (for instance during a scrolling.) This property lets you persist the cache in memory after its initial usage. Persisting the cache consumes more memory but may prevent frequent garbage collection is the cache is created over and over again. By default the persistence is set to scrolling.

Must be one or more (separated by '|') of the following constant values.

ConstantValueDescription
none0x0 The drawing cache is not persisted after use.
animation0x1 The drawing cache is persisted after a layout animation.
scrolling0x2 The drawing cache is persisted after a scroll.
all0x3 The drawing cache is always persisted.

This corresponds to the global attribute resource symbol persistentDrawingCache.

Related Methods

Constants

protected static final int CLIP_TO_PADDING_MASK

Since: API Level 1

We clip to padding when FLAG_CLIP_TO_PADDING and FLAG_PADDING_NOT_NULL are set at the same time.

Constant Value: 34 (0x00000022)

public static final int FOCUS_AFTER_DESCENDANTS

Since: API Level 1

This view will get focus only if none of its descendants want it.

Constant Value: 262144 (0x00040000)

public static final int FOCUS_BEFORE_DESCENDANTS

Since: API Level 1

This view will get focus before any of its descendants.

Constant Value: 131072 (0x00020000)

public static final int FOCUS_BLOCK_DESCENDANTS

Since: API Level 1

This view will block any of its descendants from getting focus, even if they are focusable.

Constant Value: 393216 (0x00060000)

public static final int PERSISTENT_ALL_CACHES

Since: API Level 1

Used to indicate that all drawing caches should be kept in memory.

Constant Value: 3 (0x00000003)

public static final int PERSISTENT_ANIMATION_CACHE

Since: API Level 1

Used to indicate that the animation drawing cache should be kept in memory.

Constant Value: 1 (0x00000001)

public static final int PERSISTENT_NO_CACHE

Since: API Level 1

Used to indicate that no drawing cache should be kept in memory.

Constant Value: 0 (0x00000000)

public static final int PERSISTENT_SCROLLING_CACHE

Since: API Level 1

Used to indicate that the scrolling drawing cache should be kept in memory.

Constant Value: 2 (0x00000002)

Public Constructors

public ViewGroup (Context context)

Since: API Level 1

public ViewGroup (Context context, AttributeSet attrs)

Since: API Level 1

public ViewGroup (Context context, AttributeSet attrs, int defStyle)

Since: API Level 1

Public Methods

public void addFocusables (ArrayList<View> views, int direction, int focusableMode)

Since: API Level 4

Adds any focusable views that are descendants of this view (possibly including this view if it is focusable itself) to views. This method adds all focusable views regardless if we are in touch mode or only views focusable in touch mode if we are in touch mode depending on the focusable mode paramater.

Parameters
views Focusable views found so far or null if all we are interested is the number of focusables.
direction The direction of the focus.
focusableMode The type of focusables to be added.

public void addFocusables (ArrayList<View> views, int direction)

Since: API Level 1

Add any focusable views that are descendants of this view (possibly including this view if it is focusable itself) to views. If we are in touch mode, only add views that are also focusable in touch mode.

Parameters
views Focusable views found so far
direction The direction of the focus

public boolean addStatesFromChildren ()

Since: API Level 1

Returns whether this ViewGroup's drawable states also include its children's drawable states. This is used, for example, to make a group appear to be focused when its child EditText or button is focused.

public void addTouchables (ArrayList<View> views)

Since: API Level 1

Add any touchable views that are descendants of this view (possibly including this view if it is touchable itself) to views.

Parameters
views Touchable views found so far

public void addView (View child, int index, ViewGroup.LayoutParams params)

Since: API Level 1

Adds a child view with the specified layout parameters.

Parameters
child the child view to add
index the position at which to add the child
params the layout parameters to set on the child

public void addView (View child, ViewGroup.LayoutParams params)

Since: API Level 1

Adds a child view with the specified layout parameters.

Parameters
child the child view to add
params the layout parameters to set on the child

public void addView (View child, int index)

Since: API Level 1

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.

Parameters
child the child view to add
index the position at which to add the child

public void addView (View child)

Since: API Level 1

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.

Parameters
child the child view to add

public void addView (View child, int width, int height)

Since: API Level 1

Adds a child view with this ViewGroup's default layout parameters and the specified width and height.

Parameters
child the child view to add

public void bringChildToFront (View child)

Since: API Level 1

Change the z order of the child so it's on top of all other children

public void childDrawableStateChanged (View child)

Since: API Level 1

If {link #addStatesFromChildren} is true, refreshes this group's drawable state (to include the states from its children).

Parameters
child The child whose drawable state has changed.

public void clearChildFocus (View child)

Since: API Level 1

Called when a child of this parent is giving up focus

Parameters
child The view that is giving up focus

public void clearDisappearingChildren ()

Since: API Level 1

Removes any pending animations for views that have been removed. Call this if you don't want animations for exiting views to stack up.

public void clearFocus ()

Since: API Level 1

Called when this view wants to give up focus. This will cause onFocusChanged(boolean, int, android.graphics.Rect) to be called.

public void dispatchConfigurationChanged (Configuration newConfig)

Since: API Level 8

Dispatch a notification about a resource configuration change down the view hierarchy. ViewGroups should override to route to their children.

Parameters
newConfig The new resource configuration.

public void dispatchDisplayHint (int hint)

Since: API Level 8

Dispatch a hint about whether this view is displayed. For instance, when a View moves out of the screen, it might receives a display hint indicating the view is not displayed. Applications should not rely on this hint as there is no guarantee that they will receive one.

Parameters
hint A hint about whether or not this view is displayed: VISIBLE or INVISIBLE.

public boolean dispatchDragEvent (DragEvent event)

Since: API Level 11

Detects if this View is enabled and has a drag event listener. If both are true, then it calls the drag event listener with the 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.

!!! TODO: write real docs

public boolean dispatchKeyEvent (KeyEvent event)

Since: API Level 1

Dispatch a key event to the next view on the focus path. This path runs from the top of the view tree down to the currently focused view. If this view has focus, it will dispatch to itself. Otherwise it will dispatch the next node down the focus path. This method also fires any key listeners.

Parameters
event The key event to be dispatched.
Returns
  • True if the event was handled, false otherwise.

public boolean dispatchKeyEventPreIme (KeyEvent event)

Since: API Level 3

Dispatch a key event before it is processed by any input method associated with the view hierarchy. This can be used to intercept key events in special situations before the IME consumes them; a typical example would be handling the BACK key to update the application's UI instead of allowing the IME to see it and close itself.

Parameters
event The key event to be dispatched.
Returns
  • True if the event was handled, false otherwise.