Build 1.0_r1(from source)

android.view
Class ViewGroup

java.lang.Object
  extended by android.view.View
      extended by android.view.ViewGroup
All Implemented Interfaces:
Drawable.Callback, KeyEvent.Callback, ViewManager, ViewParent
Direct Known Subclasses:
AbsoluteLayout, AdapterView, FrameLayout, LinearLayout, RelativeLayout

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.


Nested Class Summary
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.
 
Nested classes/interfaces inherited from class android.view.View
View.AttachInfo, View.BaseSavedState, View.CheckForLongPress, View.MeasureSpec, View.OnClickListener, View.OnCreateContextMenuListener, View.OnFocusChangeListener, View.OnKeyListener, View.OnLongClickListener, View.OnTouchListener
 
Field Summary
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_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 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.
 
Fields inherited from class android.view.View
ALPHA_SET, ANIMATION_STARTED, CLICKABLE, DISABLED, DRAW_MASK, DRAWABLE_STATE_DIRTY, DRAWING_CACHE_ENABLED, DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, DRAWING_CACHE_QUALITY_MASK, DRAWING_CACHE_VALID, DRAWN, DUPLICATE_PARENT_STATE, EMPTY_STATE_SET, ENABLED, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_MASK, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FADING_EDGE_HORIZONTAL, FADING_EDGE_MASK, FADING_EDGE_NONE, FADING_EDGE_VERTICAL, FIRST_STATE_SET, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLE_IN_TOUCH_MODE, FOCUSED, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, FORCE_LAYOUT, GONE, HAS_BOUNDS, INVISIBLE, IS_ROOT_NAMESPACE, KEEP_SCREEN_ON, LAST_STATE_SET, LONG_CLICKABLE, mAttachInfo, mBottom, mContext, mCurrentAnimation, MEASURED_DIMENSION_SET, mID, MIDDLE_STATE_SET, mLayoutParams, mLeft, mLocation, mMeasuredHeight, mMeasuredWidth, mOnClickListener, mOnCreateContextMenuListener, mOnFocusChangeListener, mOnLongClickListener, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mParent, mPrivateFlags, mRight, mScrollX, mScrollY, mTag, mTop, mUserPaddingBottom, mUserPaddingRight, mViewFlags, mWindowAttachCount, NO_ID, ONLY_DRAWS_BACKGROUND, 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_FIRST_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_LAST_STATE_SET, PRESSED_MIDDLE_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_SINGLE_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, REQUEST_TRANSPARENT_REGIONS, SAVE_DISABLED, SAVE_DISABLED_MASK, SCROLLBARS_HORIZONTAL, SCROLLBARS_INSET_MASK, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_MASK, SCROLLBARS_NONE, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_MASK, SCROLLBARS_OUTSIDE_OVERLAY, SCROLLBARS_STYLE_MASK, SCROLLBARS_VERTICAL, SELECTED, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SINGLE_STATE_SET, sInstanceCount, SKIP_DRAW, SOUND_EFFECTS_ENABLED, VIEW_LOG_TAG, VISIBILITY_MASK, VISIBLE, WANTS_FOCUS, WILL_NOT_CACHE_DRAWING, WILL_NOT_DRAW, WINDOW_FOCUSED_STATE_SET
 
Constructor Summary
ViewGroup(Context context)
           
ViewGroup(Context context, AttributeSet attrs)
           
ViewGroup(Context context, AttributeSet attrs, int defStyle)
           
 
Method Summary
 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)
          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 childDrawableStateChanged(View child)
          If {link #addStatesFromChildren} is true, refreshes this group's drawable state (to include the states from its children).
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 theparent.
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 view from their parent.
(package private)  void dispatchAttachedToWindow(View.AttachInfo info, int visibility)
          
(package private)  void dispatchCollectViewAttributes(int visibility)
          Private function to aggregate all per-view attributes in to the view root.
(package private)  void dispatchDetachedFromWindow()
          
protected  void dispatchDraw(Canvas canvas)
          Called by draw to draw the child views.
protected  void dispatchFreezeSelfOnly(SparseArray<Parcelable> container)
          Perform dispatching of a freeze() to only this view, not to its children.
 boolean dispatchKeyEvent(KeyEvent event)
          Dispatch a key event to the next view on the focus path.
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.
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.
protected  void dispatchThawSelfOnly(SparseArray<Parcelable> container)
          Perform dispatching of a thaw() 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.
 void dispatchWindowFocusChanged(boolean hasFocus)
          Called when the window containing this view gains or loses window focus.
 void dispatchWindowVisibilityChanged(int visibility)
          Dispatch a window visibility change down the view hierarchy.
protected  void 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.
 View findFocus()
          Find the view in the hierarchy rooted at this view that currently has focus.
protected  View findViewTraversal(int id)
          
protected  View findViewWithTagTraversal(Object tag)
          
protected  boolean fitSystemWindows(Rect insets)
          Apply the insets for system windows to this view, if the FITS_SYSTEM_WINDOWS flag is set
 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)
          
 boolean getChildVisibleRect(View child, Rect r, Point offset)
          
 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 getPersistentDrawingCache()
          Returns an integer indicating what types of drawing caches are kept in memory.
(package private)  void handleFocusGainInternal(int direction, Rect previouslyFocusedRect)
          Give this view focus.
 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.
 int indexOfChild(View child)
          Returns the position in the group of the specified child view.
 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.
protected  boolean isChildrenDrawnWithCacheEnabled()
          Indicates whether the ViewGroup is currently drawing its children using their drawing cache.
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.
(package private)  void offsetRectBetweenParentAndChild(View descendant, Rect rect, boolean offsetFromChildToParent, boolean clipToBounds)
          Helper method that offsets a rect either from parent to descendant or descendant to parent.
 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  int[] onCreateDrawableState(int extraSpace)
          Generate the new Drawable state for this view.
 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.
 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.
 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.
protected  void setChildrenDrawingCacheEnabled(boolean enabled)
          Enables or disables the drawing cache for each child of this view group.
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 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 showContextMenuForChild(View originalView)
          Bring up a context menu for the specified view or its ancestors.
 void startLayoutAnimation()
          Runs the layout animation.
(package private)  void unFocus()
          Called internally by the view system when a new view is getting focus.
 void updateViewLayout(View view, ViewGroup.LayoutParams params)
          
 
Methods inherited from class android.view.View
applyDrawableToTransparentRegion, assignParent, bringToFront, buildDrawingCache, cancelLongPress, clearAnimation, clearFocusForRemoval, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createContextMenu, debug, debugIndent, destroyDrawingCache, dispatchKeyShortcutEvent, draw, finalize, findUserSetNextFocus, findViewById, findViewWithTag, focusSearch, forceLayout, getAnimation, getApplicationWindowToken, getBackground, getBaseline, getBottom, getBottomFadingEdgeStrength, getContext, getContextMenuInfo, getDefaultSize, getDrawableState, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFocusables, getFocusedRect, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getId, getKeepScreenOn, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMeasuredHeight, getMeasuredWidth, getNextFocusDownId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getParent, getResources, getRight, getRightFadingEdgeStrength, getRootView, getScrollBarStyle, getScrollX, getScrollY, getSolidColor, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTop, getTopFadingEdgeStrength, getTouchables, getTouchDelegate, getVerticalFadingEdgeLength, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowSession, getWindowToken, getWindowVisibility, hasWindowFocus, inflate, initializeFadingEdge, initializeScrollbars, invalidate, invalidate, invalidate, invalidateDrawable, isClickable, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isInTouchMode, isLayoutRequested, isLongClickable, isPressed, isRootNamespace, isSaveEnabled, isSelected, isShown, isSoundEffectsEnabled, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, layout, measure, mergeDrawableStates, needGlobalAttributesUpdate, offsetLeftAndRight, offsetTopAndBottom, onAttachedToWindow, onCreateContextMenu, onDetachedFromWindow, onDraw, onFinishInflate, onFocusChanged, onKeyDown, onKeyMultiple, onKeyShortcut, onKeyUp, onMeasure, onRestoreInstanceState, onSaveInstanceState, onScrollChanged, onSetAlpha, onSizeChanged, onTouchEvent, onTrackballEvent, onWindowFocusChanged, onWindowVisibilityChanged, performClick, performCollectViewAttributes, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, refreshDrawableState, removeCallbacks, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, resolveSize, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, setAnimation, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setClickable, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setEnabled, setFadingEdgeLength, setFlags, setFocusable, setFocusableInTouchMode, setFrame, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setId, setIsRootNamespace, setKeepScreenOn, setLayoutParams, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnCreateContextMenuListener, setOnFocusChangeListener, setOnKeyListener, setOnLongClickListener, setOnTouchListener, setPressed, setSaveEnabled, setScrollBarStyle, setSelected, setSoundEffectsEnabled, setTag, setTouchDelegate, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVisibility, setWillNotCacheDrawing, setWillNotDraw, showContextMenu, startAnimation, unscheduleDrawable, unscheduleDrawable, verifyDrawable, willNotCacheDrawing, willNotDraw
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface android.view.ViewParent
createContextMenu, getParent, isLayoutRequested, requestLayout
 

Field Detail

mDisappearingChildren

protected ArrayList<View> mDisappearingChildren
Views which have been hidden or removed which need to be animated on their way out. This field should be made private, so it is hidden from the SDK.


mOnHierarchyChangeListener

protected ViewGroup.OnHierarchyChangeListener mOnHierarchyChangeListener
Listener used to propagate events indicating when children are added and/or removed from a view group. This field should be made private, so it is hidden from the SDK.


mGroupFlags

protected int mGroupFlags
Internal flags. This field should be made private, so it is hidden from the SDK.


FLAG_USE_CHILD_DRAWING_ORDER

protected static final 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.

See Also:
Constant Field Values

FLAG_SUPPORT_STATIC_TRANSFORMATIONS

protected static final 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. Any subclass overriding getChildStaticTransformation(View, android.view.animation.Transformation) should set this flags in mGroupFlags. This flag needs to be removed until we can add a setter for it. People can't be directly stuffing values in to mGroupFlags!!!

See Also:
Constant Field Values

FOCUS_BEFORE_DESCENDANTS

public static final int FOCUS_BEFORE_DESCENDANTS
This view will get focus before any of its descendants.

See Also:
Constant Field Values

FOCUS_AFTER_DESCENDANTS

public static final int FOCUS_AFTER_DESCENDANTS
This view will get focus only if none of its descendants want it.

See Also:
Constant Field Values

FOCUS_BLOCK_DESCENDANTS

public static final int FOCUS_BLOCK_DESCENDANTS
This view will block any of its descendants from getting focus, even if they are focusable.

See Also:
Constant Field Values

mPersistentDrawingCache

protected int mPersistentDrawingCache
Indicates which types of drawing caches are to be kept in memory. This field should be made private, so it is hidden from the SDK.


PERSISTENT_NO_CACHE

public static final int PERSISTENT_NO_CACHE
Used to indicate that no drawing cache should be kept in memory.

See Also:
Constant Field Values

PERSISTENT_ANIMATION_CACHE

public static final int PERSISTENT_ANIMATION_CACHE
Used to indicate that the animation drawing cache should be kept in memory.

See Also:
Constant Field Values

PERSISTENT_SCROLLING_CACHE

public static final int PERSISTENT_SCROLLING_CACHE
Used to indicate that the scrolling drawing cache should be kept in memory.

See Also:
Constant Field Values

PERSISTENT_ALL_CACHES

public static final int PERSISTENT_ALL_CACHES
Used to indicate that all drawing caches should be kept in memory.

See Also:
Constant Field Values

CLIP_TO_PADDING_MASK

protected static final 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.

See Also:
Constant Field Values
Constructor Detail

ViewGroup

public ViewGroup(Context context)

ViewGroup

public ViewGroup(Context context,
                 AttributeSet attrs)

ViewGroup

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

getDescendantFocusability

public int getDescendantFocusability()
Gets the descendant focusability of this view group. The descendant focusability defines the relationship between this view group and its descendants when looking for a view to take focus in requestFocus(int, android.graphics.Rect).

Returns:
one of FOCUS_BEFORE_DESCENDANTS, FOCUS_AFTER_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS.

setDescendantFocusability

public void setDescendantFocusability(int focusability)
Set the descendant focusability of this view group. This defines the relationship between this view group and its descendants when looking for a view to take focus in requestFocus(int, android.graphics.Rect).

Parameters:
focusability - one of FOCUS_BEFORE_DESCENDANTS, FOCUS_AFTER_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS.

handleFocusGainInternal

void handleFocusGainInternal(int direction,
                             Rect previouslyFocusedRect)
Give this view focus. This will cause View.onFocusChanged(boolean, int, android.graphics.Rect) to be called. Note: this does not check whether this View should get focus, it just gives it focus no matter what. It should only be called internally by framework code that knows what it is doing, namely View.requestFocus(int, Rect).

Overrides:
handleFocusGainInternal in class View
Parameters:
direction - values are View.FOCUS_UP, View.FOCUS_DOWN, View.FOCUS_LEFT or View.FOCUS_RIGHT. This is the direction which focus moved when requestFocus() is called. It may not always apply, in which case use the default View.FOCUS_DOWN.
previouslyFocusedRect - The rectangle of the view that had focus prior in this View's coordinate system.

requestChildFocus

public void requestChildFocus(View child,
                              View focused)
Called when a child of this parent wants focus

Specified by:
requestChildFocus in interface ViewParent
Parameters:
child - The child of this ViewParent that wants focus. This view will contain the focused view. It is not necessarily the view that actually has focus.
focused - The view that is a descendant of child that actually has focus

focusableViewAvailable

public void focusableViewAvailable(View v)
Tells the parent that a new focusable view has become available. This is to handle transitions from the case where there are no focusable views to the case where the first focusable view appears.

Specified by:
focusableViewAvailable in interface ViewParent
Parameters:
v - The view that has become newly focusable

showContextMenuForChild

public boolean showContextMenuForChild(View originalView)
Bring up a context menu for the specified view or its ancestors.

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.

Specified by:
showContextMenuForChild in interface ViewParent
Parameters:
originalView - The source view where the context menu was first invoked
Returns:
true if a context menu was displayed

focusSearch

public View focusSearch(View focused,
                        int direction)
Find the nearest view in the specified direction that wants to take focus.

Specified by:
focusSearch in interface ViewParent
Parameters:
focused - The view that currently has focus
direction - One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT, or 0 for not applicable.

requestChildRectangleOnScreen

public 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. ViewGroups overriding this can trust that:

ViewGroups overriding this should uphold the contract:


dispatchUnhandledMove

public 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. This is called when the focused view did not consume the key internally, nor could the view system find a new view in the requested direction to give focus to.

Overrides:
dispatchUnhandledMove in class View
Parameters:
focused - The currently focused view.
direction - The direction focus wants to move. One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT.
Returns:
True if the this view consumed this unhandled move.

clearChildFocus

public void clearChildFocus(View child)
Called when a child of this parent is giving up focus

Specified by:
clearChildFocus in interface ViewParent
Parameters:
child - The view that is giving up focus

clearFocus

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

Overrides:
clearFocus in class View

unFocus

void unFocus()
Called internally by the view system when a new view is getting focus. This is what clears the old focus.

Overrides:
unFocus in class View

getFocusedChild

public View getFocusedChild()
Returns the focused child of this view, if any. The child may have focus or contain focus.

Returns:
the focused child or null.

hasFocus

public boolean hasFocus()
Returns true if this view has or contains focus

Overrides:
hasFocus in class View
Returns:
true if this view has or contains focus

findFocus

public View findFocus()
Description copied from class: View
Find the view in the hierarchy rooted at this view that currently has focus.

Overrides:
findFocus in class View
Returns:
The view that currently has focus, or null if no focused view can be found.

hasFocusable

public boolean hasFocusable()
Returns true if this view is focusable or if it contains a reachable View for which View.hasFocusable() returns true. A "reachable hasFocusable()" is a View whose parents do not block descendants focus. Only View.VISIBLE views are considered focusable.

Overrides:
hasFocusable in class View
Returns:
True if the view is focusable or if the view contains a focusable View, false otherwise.
See Also:
FOCUS_BLOCK_DESCENDANTS

addFocusables

public 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. If we are in touch mode, only add views that are also focusable in touch mode.

Overrides:
addFocusables in class View
Parameters:
views - Focusable views found so far
direction - The direction of the focus

dispatchWindowFocusChanged

public void dispatchWindowFocusChanged(boolean hasFocus)
Called when the window containing this view gains or loses window focus. ViewGroups should override to route to their children.

Overrides:
dispatchWindowFocusChanged in class View
Parameters:
hasFocus - True if the window containing this view now has focus, false otherwise.

addTouchables

public 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.

Overrides:
addTouchables in class View
Parameters:
views - Touchable views found so far

dispatchWindowVisibilityChanged

public void dispatchWindowVisibilityChanged(int visibility)
Dispatch a window visibility change down the view hierarchy. ViewGroups should override to route to their children.

Overrides:
dispatchWindowVisibilityChanged in class View
Parameters:
visibility - The new visibility of the window.
See Also:
View.onWindowVisibilityChanged(int)

recomputeViewAttributes

public void recomputeViewAttributes(View child)
Tell view hierarchy that the global view attributes need to be re-evaluated.

Specified by:
recomputeViewAttributes in interface ViewParent
Parameters:
child - View whose attributes have changed.

dispatchCollectViewAttributes

void dispatchCollectViewAttributes(int visibility)
Description copied from class: View
Private function to aggregate all per-view attributes in to the view root.

Overrides:
dispatchCollectViewAttributes in class View

bringChildToFront

public void bringChildToFront(View child)
Change the z order of the child so it's on top of all other children

Specified by:
bringChildToFront in interface ViewParent

dispatchKeyEvent

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

Overrides:
dispatchKeyEvent in class View
Parameters:
event - The key event to be dispatched.
Returns:
True if the event was handled, false otherwise.

dispatchTrackballEvent

public boolean dispatchTrackballEvent(MotionEvent event)
Pass a trackball motion event down to the focused view.

Overrides:
dispatchTrackballEvent in class View
Parameters:
event - The motion event to be dispatched.
Returns:
True if the event was handled by the view, false otherwise.

dispatchTouchEvent

public boolean dispatchTouchEvent(MotionEvent ev)
Pass the touch screen motion event down to the target view, or this view if it is the target.

Overrides:
dispatchTouchEvent in class View
Parameters:
ev - The motion event to be dispatched.
Returns:
True if the event was handled by the view, false otherwise.

requestDisallowInterceptTouchEvent

public void requestDisallowInterceptTouchEvent(boolean disallowIntercept)
Called when a child does not want this parent and its ancestors to intercept touch events with 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.

Specified by:
requestDisallowInterceptTouchEvent in interface ViewParent
Parameters:
disallowIntercept - True if the child does not want the parent to intercept touch events.

onInterceptTouchEvent

public boolean onInterceptTouchEvent(MotionEvent ev)
Implement this method to intercept all touch screen motion events. This allows you to watch events as they are dispatched to your children, and take ownership of the current gesture at any point.

Using this function takes some care, as it has a fairly complicated interaction with View.onTouchEvent(MotionEvent), and using it requires implementing that method as well as this one in the correct way. Events will be received in the following order:

  1. You will receive the down event here.
  2. The down event will be handled either by a child of this view group, or given to your own onTouchEvent() method to handle; this means you should implement onTouchEvent() to return true, so you will continue to see the rest of the gesture (instead of looking for a parent view to handle it). Also, by returning true from onTouchEvent(), you will not receive any following events in onInterceptTouchEvent() and all touch processing must happen in onTouchEvent() like normal.
  3. For as long as you return false from this function, each following event (up to and including the final up) will be delivered first here and then to the target's onTouchEvent().
  4. If you return true from here, you will not receive any following events: the target view will receive the same event but with the action MotionEvent.ACTION_CANCEL, and all further events will be delivered to your onTouchEvent() method and no longer appear here.

Parameters:
ev - The motion event being dispatched down the hierarchy.
Returns:
Return true to steal motion events from the children and have them dispatched to this ViewGroup through onTouchEvent(). The current target will receive an ACTION_CANCEL event, and no further messages will be delivered here.

requestFocus

public 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. The rectangle can help give larger views a finer grained hint about where focus is coming from, and therefore, where to show selection, or forward focus change internally. A view will not actually take focus if it is not focusable (View.isFocusable() returns false), or if it is focusable and it is not focusable in touch mode (View.isFocusableInTouchMode()) while the device is in touch mode. A View will not take focus if it is not visible. A View will not take focus if one of its parents has getDescendantFocusability() equal 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.

Overrides:
requestFocus in class View
Parameters:
direction - One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT
previouslyFocusedRect - The rectangle (in this View's coordinate system) to give a finer grained hint about where focus is coming from. May be null if there is no hint.
Returns:
Whether this view or one of its descendants actually took focus.
See Also:
FOCUS_BEFORE_DESCENDANTS, FOCUS_AFTER_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS, onRequestFocusInDescendants(int, android.graphics.Rect)

onRequestFocusInDescendants

protected boolean onRequestFocusInDescendants(int direction,
                                              Rect previouslyFocusedRect)
Look for a descendant to call 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.

Parameters:
direction - One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT
previouslyFocusedRect - The rectangle (in this View's coordinate system) to give a finer grained hint about where focus is coming from. May be null if there is no hint.
Returns:
Whether focus was taken.

dispatchAttachedToWindow

void dispatchAttachedToWindow(View.AttachInfo info,
                              int visibility)

Overrides:
dispatchAttachedToWindow in class View
Parameters:
info - the View.AttachInfo to associated with this view

dispatchDetachedFromWindow

void dispatchDetachedFromWindow()

Overrides:
dispatchDetachedFromWindow in class View

setPadding

public void setPadding(int left,
                       int top,
                       int right,
                       int bottom)
Sets the padding. The view may add on the space required to display the scrollbars, depending on the style and visibility of the scrollbars. So the values returned from View.getPaddingLeft(), View.getPaddingTop(), View.getPaddingRight() and View.getPaddingBottom() may be different from the values set in this call.

Overrides:
setPadding in class View
Parameters:
left - the left padding in pixels
top - the top padding in pixels
right - the right padding in pixels
bottom - the bottom padding in pixels

dispatchSaveInstanceState

protected void dispatchSaveInstanceState(SparseArray<Parcelable> container)
Called by 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.

Overrides:
dispatchSaveInstanceState in class View
Parameters:
container - The SparseArray in which to save the view's state.
See Also:
View.dispatchRestoreInstanceState(android.util.SparseArray), View.saveHierarchyState(android.util.SparseArray), View.onSaveInstanceState()

dispatchFreezeSelfOnly

protected void dispatchFreezeSelfOnly(SparseArray<Parcelable> container)
Perform dispatching of a freeze() to only this view, not to its children. For use when overriding dispatchFreeze() to allow subclasses to freeze their own state but not the state of their children.

Parameters:
container - the container

dispatchRestoreInstanceState

protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container)
Called by View.restoreHierarchyState(android.util.SparseArray) to retrieve the state for this view and its children. May be overridden to modify how restoreing happens to a view's children; for example, some views may want to not store state for their children.

Overrides:
dispatchRestoreInstanceState in class View
Parameters:
container - The SparseArray which holds previously saved state.
See Also:
View.dispatchSaveInstanceState(android.util.SparseArray), View.restoreHierarchyState(android.util.SparseArray), View.onRestoreInstanceState(android.os.Parcelable)

dispatchThawSelfOnly

protected void dispatchThawSelfOnly(SparseArray<Parcelable> container)
Perform dispatching of a thaw() to only this view, not to its children. For use when overriding dispatchThaw() to allow subclasses to thaw their own state but not the state of their children.

Parameters:
container - the container

setChildrenDrawingCacheEnabled

protected void setChildrenDrawingCacheEnabled(boolean enabled)
Enables or disables the drawing cache for each child of this view group.

Parameters:
enabled - true to enable the cache, false to dispose of it

onAnimationStart

protected void onAnimationStart()
Description copied from class: View
Invoked by a parent ViewGroup to notify the start of the animation currently associated with this view. If you override this method, always call super.onAnimationStart();

Overrides:
onAnimationStart in class View
See Also:
View.setAnimation(android.view.animation.Animation), View.getAnimation()

onAnimationEnd

protected void onAnimationEnd()
Description copied from class: View
Invoked by a parent ViewGroup to notify the end of the animation currently associated with this view. If you override this method, always call super.onAnimationEnd();

Overrides:
onAnimationEnd in class View
See Also:
View.setAnimation(android.view.animation.Animation), View.getAnimation()

dispatchDraw

protected void dispatchDraw(Canvas canvas)
Called by draw to draw the child views. This may be overridden by derived classes to gain control just before its children are drawn (but after its own view has been drawn).

Overrides:
dispatchDraw in class View
Parameters:
canvas - the canvas on which to draw the view

getChildDrawingOrder

protected int getChildDrawingOrder(int childCount,
                                   int i)
Returns the index of the child to draw for this iteration. Override this if you want to change the drawing order of children. By default, it returns i.

NOTE: In order for this method to be called, the FLAG_USE_CHILD_DRAWING_ORDER must be set.

Parameters:
i - The current iteration.
Returns:
The index of the child to draw this iteration.

drawChild

protected boolean drawChild(Canvas canvas,
                            View child,
                            long drawingTime)
Draw one child of this View Group. This method is responsible for getting the canvas in the right state. This includes clipping, translating so that the child's scrolled origin is at 0, 0, and applying any animation transformations.

Parameters:
canvas - The canvas on which to draw the child
child - Who to draw
drawingTime - The time at which draw is occuring
Returns:
True if an invalidate() was issued

setClipChildren

public void setClipChildren(boolean clipChildren)
By default, children are clipped to their bounds before drawing. This allows view groups to override this behavior for animations, etc.

Parameters:
clipChildren - true to clip children to their bounds, false otherwise

setClipToPadding

public void setClipToPadding(boolean clipToPadding)
By default, children are clipped to the padding of the ViewGroup. This allows view groups to override this behavior

Parameters:
clipToPadding - true to clip children to the padding of the group, false otherwise

dispatchSetSelected

public void dispatchSetSelected(boolean selected)
Dispatch setSelected to all of this View's children.

Overrides:
dispatchSetSelected in class View
Parameters:
selected - The new selected state
See Also:
View.setSelected(boolean)

dispatchSetPressed

protected void dispatchSetPressed(boolean pressed)
Description copied from class: View
Dispatch setPressed to all of this View's children.

Overrides:
dispatchSetPressed in class View
Parameters:
pressed - The new pressed state
See Also:
View.setPressed(boolean)

getChildStaticTransformation

protected boolean getChildStaticTransformation(View child,
                                               Transformation t)


findViewTraversal

protected View findViewTraversal(int id)

Overrides:
findViewTraversal in class View
Parameters:
id - the id of the view to be found
Returns:
the view of the specified id, null if cannot be found

findViewWithTagTraversal

protected View findViewWithTagTraversal(Object tag)

Overrides:
findViewWithTagTraversal in class View
Parameters:
tag - the tag of the view to be found
Returns:
the view of specified tag, null if cannot be found

addView

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.

Parameters:
child - the child view to add
See Also:
generateDefaultLayoutParams()

addView

public void addView(View child,
                    int index)
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
See Also:
generateDefaultLayoutParams()

addView

public 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.

Parameters:
child - the child view to add

addView

public void addView(View child,
                    ViewGroup.LayoutParams params)
Adds a child view with the specified layout parameters.

Specified by:
addView in interface ViewManager
Parameters:
child - the child view to add
params - the layout parameters to set on the child

addView

public void addView(View child,
                    int index,
                    ViewGroup.LayoutParams params)
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

updateViewLayout

public void updateViewLayout(View view,
                             ViewGroup.LayoutParams params)

Specified by:
updateViewLayout in interface ViewManager

checkLayoutParams

protected boolean checkLayoutParams(ViewGroup.LayoutParams p)


setOnHierarchyChangeListener

public void setOnHierarchyChangeListener(ViewGroup.OnHierarchyChangeListener listener)
Register a callback to be invoked when a child is added to or removed from this view.

Parameters:
listener - the callback to invoke on hierarchy change

addViewInLayout

protected boolean addViewInLayout(View child,
                                  int index,
                                  ViewGroup.LayoutParams params)
Adds a view during layout. This is useful if in your onLayout() method, you need to add more views (as does the list view for example). If index is negative, it means put it at the end of the list.

Parameters:
child - the view to add to the group
index - the index at which the child must be added
params - the layout parameters to associate with the child
Returns:
true if the child was added, false otherwise

addViewInLayout

protected boolean addViewInLayout(View child,
                                  int index,
                                  ViewGroup.LayoutParams params,
                                  boolean preventRequestLayout)
Adds a view during layout. This is useful if in your onLayout() method, you need to add more views (as does the list view for example). If index is negative, it means put it at the end of the list.

Parameters:
child - the view to add to the group
index - the index at which the child must be added
params - the layout parameters to associate with the child
preventRequestLayout - if true, calling this method will not trigger a layout request on child
Returns:
true if the child was added, false otherwise

cleanupLayoutState

protected void cleanupLayoutState(View child)
Prevents the specified child to be laid out during the next layout pass.

Parameters:
child - the child on which to perform the cleanup

attachLayoutAnimationParameters

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.

Parameters:
child - the child to associate with animation parameters
params - the child's layout parameters which hold the animation parameters
index - the index of the child in the view group
count - the number of children in the view group

removeView

public void removeView(View view)

Specified by:
removeView in interface ViewManager

removeViewInLayout

public void removeViewInLayout(View view)
Removes a view during layout. This is useful if in your onLayout() method, you need to remove more views.

Parameters:
view - the view to remove from the group

removeViewsInLayout

public void removeViewsInLayout(int start,
                                int count)
Removes a range of views during layout. This is useful if in your onLayout() method, you need to remove more views.

Parameters:
start - the index of the first view to remove from the group
count - the number of views to remove from the group

removeViewAt

public void removeViewAt(int index)
Removes the view at the specified position in the group.

Parameters:
index - the position in the group of the view to remove

removeViews

public void removeViews(int start,
                        int count)
Removes the specified range of views from the group.

Parameters:
start - the first position in the group of the range of views to remove
count - the number of views to remove

removeAllViews

public void removeAllViews()
Call this method to remove all child views from the ViewGroup.


removeAllViewsInLayout

public void removeAllViewsInLayout()
Called by a ViewGroup subclass to remove child views from itself, when it must first know its size on screen before it can calculate how many child views it will render. An example is a Gallery or a ListView, which may "have" 50 children, but actually only render the number of children that can currently fit inside the object on screen. Do not call this method unless you are extending ViewGroup and understand the view measuring and layout pipeline.


removeDetachedView

protected void removeDetachedView(View child,
                                  boolean animate)
Finishes the removal of a detached view. This method will dispatch the detached from window event and notify the hierarchy change listener.

Parameters:
child - the child to be definitely removed from the view hierarchy
animate - if true and the view has an animation, the view is placed in the disappearing views list, otherwise, it is detached from the window
See Also:
attachViewToParent(View, int, android.view.ViewGroup.LayoutParams), detachAllViewsFromParent(), detachViewFromParent(View), detachViewFromParent(int)

attachViewToParent

protected void attachViewToParent(View child,
                                  int index,
                                  ViewGroup.LayoutParams params)
Attaches a view to this view group. Attaching a view assigns this group as the parent, sets the layout parameters and puts the view in the list of children so it can be retrieved by calling getChildAt(int). This method should be called only for view which were detached from their parent.

Parameters:
child - the child to attach
index - the index at which the child should be attached
params - the layout parameters of the child
See Also:
removeDetachedView(View, boolean), detachAllViewsFromParent(), detachViewFromParent(View), detachViewFromParent(int)

detachViewFromParent

protected void detachViewFromParent(View child)
Detaches a view from its parent. Detaching a view should be temporary and followed either by a call to attachViewToParent(View, int, android.view.ViewGroup.LayoutParams) or a call to removeDetachedView(View, boolean). When a view is detached, its parent is null and cannot be retrieved by a call to getChildAt(int).

Parameters:
child - the child to detach
See Also:
detachViewFromParent(int), detachViewsFromParent(int, int), detachAllViewsFromParent(), attachViewToParent(View, int, android.view.ViewGroup.LayoutParams), removeDetachedView(View, boolean)

detachViewFromParent

protected void detachViewFromParent(int index)
Detaches a view from its parent. Detaching a view should be temporary and followed either by a call to attachViewToParent(View, int, android.view.ViewGroup.LayoutParams) or a call to removeDetachedView(View, boolean). When a view is detached, its parent is null and cannot be retrieved by a call to getChildAt(int).

Parameters:
index - the index of the child to detach
See Also:
detachViewFromParent(View), detachAllViewsFromParent(), detachViewsFromParent(int, int), attachViewToParent(View, int, android.view.ViewGroup.LayoutParams), removeDetachedView(View, boolean)

detachViewsFromParent

protected void detachViewsFromParent(int start,
                                     int count)
Detaches a range of view from their parent. Detaching a view should be temporary and followed either by a call to attachViewToParent(View, int, android.view.ViewGroup.LayoutParams) or a call to removeDetachedView(View, boolean). When a view is detached, its parent is null and cannot be retrieved by a call to getChildAt(int).

Parameters:
start - the first index of the childrend range to detach
count - the number of children to detach
See Also:
detachViewFromParent(View), detachViewFromParent(int), detachAllViewsFromParent(), attachViewToParent(View, int, android.view.ViewGroup.LayoutParams), removeDetachedView(View, boolean)

detachAllViewsFromParent

protected void detachAllViewsFromParent()
Detaches all views from theparent. Detaching a view should be temporary and followed either by a call to attachViewToParent(View, int, android.view.ViewGroup.LayoutParams) or a call to removeDetachedView(View, boolean). When a view is detached, its parent is null and cannot be retrieved by a call to getChildAt(int).

See Also:
detachViewFromParent(View), detachViewFromParent(int), detachViewsFromParent(int, int), attachViewToParent(View, int, android.view.ViewGroup.LayoutParams), removeDetachedView(View, boolean)

invalidateChild

public final void invalidateChild(View child,
                                  Rect dirty)
Don't call or override this method. It is used for the implementation of the view hierarchy.

Specified by:
invalidateChild in interface ViewParent
Parameters:
child - The child which is dirty
dirty - The area within the child that is invalid

invalidateChildInParent

public ViewParent invalidateChildInParent(int[] location,
                                          Rect dirty)
Don't call or override this method. It is used for the implementation of the view hierarchy. This implementation returns null if this ViewGroup does not have a parent, if this ViewGroup is already fully invalidated or if the dirty rectangle does not intersect with this ViewGroup's bounds.

Specified by:
invalidateChildInParent in interface ViewParent
Parameters:
location - An array of 2 ints containing the left and top coordinates of the child to invalidate
dirty - The area within the child that is invalid
Returns:
the parent of this ViewParent or null

offsetDescendantRectToMyCoords

public final void offsetDescendantRectToMyCoords(View descendant,
                                                 Rect rect)
Offset a rectangle that is in a descendant's coordinate space into our coordinate space.

Parameters:
descendant - A descendant of this view
rect - A rectangle defined in descendant's coordinate space.

offsetRectIntoDescendantCoords

public final void offsetRectIntoDescendantCoords(View descendant,
                                                 Rect rect)
Offset a rectangle that is in our coordinate space into an ancestor's coordinate space.

Parameters:
descendant - A descendant of this view
rect - A rectangle defined in descendant's coordinate space.

offsetRectBetweenParentAndChild

void offsetRectBetweenParentAndChild(View descendant,
                                     Rect rect,
                                     boolean offsetFromChildToParent,
                                     boolean clipToBounds)
Helper method that offsets a rect either from parent to descendant or descendant to parent.


offsetChildrenTopAndBottom

public void offsetChildrenTopAndBottom(int offset)
Offset the vertical location of all children of this view by the specified number of pixels.

Parameters:
offset - the number of pixels to offset

getChildVisibleRect

public boolean getChildVisibleRect(View child,
                                   Rect r,
                                   Point offset)

Specified by:
getChildVisibleRect in interface ViewParent

onLayout

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. Derived classes with children should override this method and call layout on each of their their children.

Overrides:
onLayout in class View
Parameters:
changed - This is a new size or position for this view
l - Left position, relative to parent
t - Top position, relative to parent
r - Right position, relative to parent
b - Bottom position, relative to parent

canAnimate

protected boolean canAnimate()
Indicates whether the view group has the ability to animate its children after the first layout.

Returns:
true if the children can be animated, false otherwise

startLayoutAnimation

public void startLayoutAnimation()
Runs the layout animation. Calling this method triggers a relayout of this view group.


scheduleLayoutAnimation

public void scheduleLayoutAnimation()
Schedules the layout animation to be played after the next layout pass of this view group. This can be used to restart the layout animation when the content of the view group changes or when the activity is paused and resumed.


setLayoutAnimation

public void setLayoutAnimation(LayoutAnimationController controller)
Sets the layout animation controller used to animate the group's children after the first layout.

Parameters:
controller - the animation controller

getLayoutAnimation

public LayoutAnimationController getLayoutAnimation()
Returns the layout animation controller used to animate the group's children.

Returns:
the current animation controller

isAnimationCacheEnabled

public boolean isAnimationCacheEnabled()
Indicates whether the children's drawing cache is used during a layout animation. By default, the drawing cache is enabled but this will prevent nested layout animations from working. To nest animations, you must disable the cache.

Returns:
true if the animation cache is enabled, false otherwise
See Also:
setAnimationCacheEnabled(boolean), View.setDrawingCacheEnabled(boolean)

setAnimationCacheEnabled

public void setAnimationCacheEnabled(boolean enabled)
Enables or disables the children's drawing cache during a layout animation. By default, the drawing cache is enabled but this will prevent nested layout animations from working. To nest animations, you must disable the cache.

Parameters:
enabled - true to enable the animation cache, false otherwise
See Also:
isAnimationCacheEnabled(), View.setDrawingCacheEnabled(boolean)

isAlwaysDrawnWithCacheEnabled

public boolean isAlwaysDrawnWithCacheEnabled()
Indicates whether this ViewGroup will always try to draw its children using their drawing cache. By default this property is enabled.

Returns:
true if the animation cache is enabled, false otherwise
See Also:
setAlwaysDrawnWithCacheEnabled(boolean), setChildrenDrawnWithCacheEnabled(boolean), View.setDrawingCacheEnabled(boolean)

setAlwaysDrawnWithCacheEnabled

public void setAlwaysDrawnWithCacheEnabled(boolean always)
Indicates whether this ViewGroup will always try to draw its children using their drawing cache. This property can be set to true when the cache rendering is slightly different from the children's normal rendering. Renderings can be different, for instance, when the cache's quality is set to low. When this property is disabled, the ViewGroup will use the drawing cache of its children only when asked to. It's usually the task of subclasses to tell ViewGroup when to start using the drawing cache and when to stop using it.

Parameters:
always - true to always draw with the drawing cache, false otherwise
See Also:
isAlwaysDrawnWithCacheEnabled(), setChildrenDrawnWithCacheEnabled(boolean), View.setDrawingCacheEnabled(boolean), View.setDrawingCacheQuality(int)

isChildrenDrawnWithCacheEnabled

protected boolean isChildrenDrawnWithCacheEnabled()
Indicates whether the ViewGroup is currently drawing its children using their drawing cache.

Returns:
true if children should be drawn with their cache, false otherwise
See Also:
setAlwaysDrawnWithCacheEnabled(boolean), setChildrenDrawnWithCacheEnabled(boolean)

setChildrenDrawnWithCacheEnabled

protected void setChildrenDrawnWithCacheEnabled(boolean enabled)
Tells the ViewGroup to draw its children using their drawing cache. This property is ignored when isAlwaysDrawnWithCacheEnabled() is true. A child's drawing cache will be used only if it has been enabled. Subclasses should call this method to start and stop using the drawing cache when they perform performance sensitive operations, like scrolling or animating.

Parameters:
enabled - true if children should be drawn with their cache, false otherwise
See Also:
setAlwaysDrawnWithCacheEnabled(boolean), isChildrenDrawnWithCacheEnabled()

getPersistentDrawingCache

public int getPersistentDrawingCache()
Returns an integer indicating what types of drawing caches are kept in memory.

Returns:
one or a combination of PERSISTENT_NO_CACHE, PERSISTENT_ANIMATION_CACHE, PERSISTENT_SCROLLING_CACHE and PERSISTENT_ALL_CACHES
See Also:
setPersistentDrawingCache(int), setAnimationCacheEnabled(boolean)

setPersistentDrawingCache

public void setPersistentDrawingCache(int drawingCacheToKeep)
Indicates what types of drawing caches should be kept in memory after they have been created.

Parameters:
drawingCacheToKeep - one or a combination of PERSISTENT_NO_CACHE, PERSISTENT_ANIMATION_CACHE, PERSISTENT_SCROLLING_CACHE and PERSISTENT_ALL_CACHES
See Also:
getPersistentDrawingCache(), setAnimationCacheEnabled(boolean)

generateLayoutParams

public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs)
Returns a new set of layout parameters based on the supplied attributes set.

Parameters:
attrs - the attributes to build the layout parameters from
Returns:
an instance of ViewGroup.LayoutParams or one of its descendants

generateLayoutParams

protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)
Returns a safe set of layout parameters based on the supplied layout params. When a ViewGroup is passed a View whose layout params do not pass the test of checkLayoutParams(android.view.ViewGroup.LayoutParams), this method is invoked. This method should return a new set of layout params suitable for this ViewGroup, possibly by copying the appropriate attributes from the specified set of layout params.

Parameters:
p - The layout parameters to convert into a suitable set of layout parameters for this ViewGroup.
Returns:
an instance of ViewGroup.LayoutParams or one of its descendants

generateDefaultLayoutParams

protected ViewGroup.LayoutParams generateDefaultLayoutParams()
Returns a set of default layout parameters. These parameters are requested when the View passed to addView(View) has no layout parameters already set. If null is returned, an exception is thrown from addView.

Returns:
a set of default layout parameters or null

debug

protected void debug(int depth)
Prints information about this view in the log output, with the tag View.VIEW_LOG_TAG. Each line in the output is preceded with an indentation defined by the depth.

Overrides:
debug in class View
Parameters:
depth - the indentation level

indexOfChild

public int indexOfChild(View child)
Returns the position in the group of the specified child view.

Parameters:
child - the view for which to get the position
Returns:
a positive integer representing the position of the view in the group, or -1 if the view does not exist in the group

getChildCount

public int getChildCount()
Returns the number of children in the group.

Returns:
a positive integer representing the number of children in the group

getChildAt

public View getChildAt(int index)
Returns the view at the specified position in the group.

Parameters:
index - the position at which to get the view from
Returns:
the view at the specified position or null if the position does not exist within the group

measureChildren

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. We skip children that are in the GONE state The heavy lifting is done in getChildMeasureSpec.

Parameters:
widthMeasureSpec - The width requirements for this view
heightMeasureSpec - The height requirements for this view

measureChild

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. The heavy lifting is done in getChildMeasureSpec.

Parameters:
child - The child to measure
parentWidthMeasureSpec - The width requirements for this view
parentHeightMeasureSpec - The height requirements for this view

measureChildWithMargins

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. The child must have MarginLayoutParams The heavy lifting is done in getChildMeasureSpec.

Parameters:
child - The child to measure
parentWidthMeasureSpec - The width requirements for this view
widthUsed - Extra space that has been used up by the parent horizontally (possibly by other children of the parent)
parentHeightMeasureSpec - The height requirements for this view
heightUsed - Extra space that has been used up by the parent vertically (possibly by other children of the parent)

getChildMeasureSpec

public static int getChildMeasureSpec(int spec,
                                      int padding,
                                      int childDimension)
Does the hard part of measureChildren: figuring out the MeasureSpec to pass to a particular child. This method figures out the right MeasureSpec for one dimension (height or width) of one child view. The goal is to combine information from our MeasureSpec with the LayoutParams of the child to get the best possible results. For example, if the this view knows its size (because its MeasureSpec has a mode of EXACTLY), and the child has indicated in its LayoutParams that it wants to be the same size as the parent, the parent should ask the child to layout given an exact size.

Parameters:
spec - The requirements for this view
padding - The padding of this view for the current dimension and margins, if applicable
childDimension - How big the child wants to be in the current dimension
Returns:
a MeasureSpec integer for the child

clearDisappearingChildren

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


gatherTransparentRegion

public boolean gatherTransparentRegion(Region region)
This is used by the RootView to perform an optimization when the view hierarchy contains one or several SurfaceView. SurfaceView is always considered transparent, but its children are not, therefore all View objects remove themselves from the global transparent region (passed as a parameter to this function).

Overrides:
gatherTransparentRegion in class View
Parameters:
region - The transparent region for this ViewRoot (window).
Returns:
Returns true if the effective visibility of the view at this point is opaque, regardless of the transparent region; returns false if it is possible for underlying windows to be seen behind the view.

requestTransparentRegion

public void requestTransparentRegion(View child)
Called when a child wants the view hierarchy to gather and report transparent regions to the window compositor. Views that "punch" holes in the view hierarchy, such as SurfaceView can use this API to improve performance of the system. When no such a view is present in the hierarchy, this optimization in unnecessary and might slightly reduce the view hierarchy performance.

Specified by:
requestTransparentRegion in interface ViewParent
Parameters:
child - the view requesting the transparent region computation

fitSystemWindows

protected boolean fitSystemWindows(Rect insets)
Description copied from class: View
Apply the insets for system windows to this view, if the FITS_SYSTEM_WINDOWS flag is set

Overrides:
fitSystemWindows in class View
Parameters:
insets - Insets for system windows
Returns:
True if this view applied the insets, false otherwise

getLayoutAnimationListener

public Animation.AnimationListener getLayoutAnimationListener()
Returns the animation listener to which layout animation events are sent.

Returns:
an Animation.AnimationListener

drawableStateChanged

protected void drawableStateChanged()
Description copied from class: View
This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

Be sure to call through to the superclass when overriding this function.

Overrides:
drawableStateChanged in class View
See Also:
Drawable.setState(int[])

onCreateDrawableState

protected int[] onCreateDrawableState(int extraSpace)
Description copied from class: View
Generate the new 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().

Overrides:
onCreateDrawableState in class View
Parameters:
extraSpace - if non-zero, this is the number of extra entries you would like in the returned array in which you can place your own states.
Returns:
Returns an array holding the current Drawable state of the view.
See Also:
View.mergeDrawableStates(int[], int[])

setAddStatesFromChildren

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


addStatesFromChildren

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


childDrawableStateChanged

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

Specified by:
childDrawableStateChanged in interface ViewParent
Parameters:
child - The child whose drawable state has changed.

setLayoutAnimationListener

public void setLayoutAnimationListener(Animation.AnimationListener animationListener)
Specifies the animation listener to which layout animation events must be sent. Only Animation.AnimationListener.onAnimationStart(Animation) and Animation.AnimationListener.onAnimationEnd(Animation) are invoked.

Parameters:
animationListener - the layout animation listener

Build 1.0_r1(from source)

Please submit a feedback, bug or feature