java.lang.Object | ||
↳ | android.view.View | |
↳ | android.view.ViewGroup |
Known Direct Subclasses
AbsoluteLayout,
AdapterView<T extends Adapter>,
FrameLayout,
LinearLayout,
RelativeLayout,
SlidingDrawer
|
Known Indirect Subclasses
AbsListView,
AbsSpinner,
AppWidgetHostView,
DatePicker,
DialerFilter,
ExpandableListView,
Gallery,
GridView,
HorizontalScrollView,
ImageSwitcher,
ListView,
MediaController,
RadioGroup,
ScrollView,
Spinner,
TabHost,
TabWidget,
TableLayout,
TableRow,
TextSwitcher,
TimePicker,
TwoLineListItem,
ViewAnimator,
ViewFlipper,
ViewSwitcher,
WebView,
ZoomControls
|
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 Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
ViewGroup.LayoutParams | LayoutParams are used by views to tell their parents how they want to be laid out. | ||||||||||
ViewGroup.MarginLayoutParams | Per-child layout information for layouts that support margins. | ||||||||||
ViewGroup.OnHierarchyChangeListener | Interface definition for a callback to be invoked when the hierarchy within this view changed. |
XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
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. |
[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 | 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. | |||||||||
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
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Add any focusable views that are descendants of this view (possibly
including this view if it is focusable itself) to views.
| |||||||||||
Returns whether this ViewGroup's drawable states also include
its children's drawable states.
| |||||||||||
Add any touchable views that are descendants of this view (possibly
including this view if it is touchable itself) to views.
| |||||||||||
Adds a child view.
| |||||||||||
Adds a child view with this ViewGroup's default layout parameters and the
specified width and height.
| |||||||||||
Adds a child view with the specified layout parameters.
| |||||||||||
Adds a child view with the specified layout parameters.
| |||||||||||
Adds a child view.
| |||||||||||
Change the z order of the child so it's on top of all other children
| |||||||||||
If {link #addStatesFromChildren} is true, refreshes this group's
drawable state (to include the states from its children).
| |||||||||||
Called when a child of this parent is giving up focus
| |||||||||||
Removes any pending animations for views that have been removed.
| |||||||||||
Called when this view wants to give up focus.
| |||||||||||
Dispatch a key event to the next view on the focus path.
| |||||||||||
Dispatch a key event before it is processed by any input method
associated with the view hierarchy.
| |||||||||||
Dispatches a key shortcut event.
| |||||||||||
Dispatch setSelected to all of this View's children.
| |||||||||||
Pass the touch screen motion event down to the target view, or this
view if it is the target.
| |||||||||||
Pass a trackball motion event down to the focused view.
| |||||||||||
This method is the last chance for the focused view and its ancestors to
respond to an arrow key.
| |||||||||||
Called when the window containing this view gains or loses window focus.
| |||||||||||
Dispatch a window visibility change down the view hierarchy.
| |||||||||||
Find the view in the hierarchy rooted at this view that currently has
focus.
| |||||||||||
Find the nearest view in the specified direction that wants to take
focus.
| |||||||||||
Tells the parent that a new focusable view has become available.
| |||||||||||
This is used by the RootView to perform an optimization when
the view hierarchy contains one or several SurfaceView.
| |||||||||||
Returns a new set of layout parameters based on the supplied attributes set.
| |||||||||||
Returns the view at the specified position in the group.
| |||||||||||
Returns the number of children in the group.
| |||||||||||
Does the hard part of measureChildren: figuring out the MeasureSpec to
pass to a particular child.
| |||||||||||
Gets the descendant focusability of this view group.
| |||||||||||
Returns the focused child of this view, if any.
| |||||||||||
Returns the layout animation controller used to animate the group's
children.
| |||||||||||
Returns the animation listener to which layout animation events are
sent.
| |||||||||||
Returns an integer indicating what types of drawing caches are kept in memory.
| |||||||||||
Returns true if this view has or contains focus
| |||||||||||
Returns true if this view is focusable or if it contains a reachable View
for which hasFocusable() returns true.
| |||||||||||
Returns the position in the group of the specified child view.
| |||||||||||
Don't call or override this method.
| |||||||||||
Don't call or override this method.
| |||||||||||
Indicates whether this ViewGroup will always try to draw its children using their
drawing cache.
| |||||||||||
Indicates whether the children's drawing cache is used during a layout
animation.
| |||||||||||
Offset a rectangle that is in a descendant's coordinate
space into our coordinate space.
| |||||||||||
Offset a rectangle that is in our coordinate space into an ancestor's
coordinate space.
| |||||||||||
Implement this method to intercept all touch screen motion events.
| |||||||||||
Tell view hierarchy that the global view attributes need to be
re-evaluated.
| |||||||||||
Call this method to remove all child views from the
ViewGroup.
| |||||||||||
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.
| |||||||||||
Removes the view at the specified position in the group.
| |||||||||||
Removes a view during layout.
| |||||||||||
Removes the specified range of views from the group.
| |||||||||||
Removes a range of views during layout.
| |||||||||||
Called when a child of this parent wants focus
| |||||||||||
Called when a child of this group wants a particular rectangle to be
positioned onto the screen.
| |||||||||||
Called when a child does not want this parent and its ancestors to
intercept touch events with
onInterceptTouchEvent(MotionEvent).
| |||||||||||
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().
| |||||||||||
Called when a child wants the view hierarchy to gather and report
transparent regions to the window compositor.
| |||||||||||
Schedules the layout animation to be played after the next layout pass
of this view group.
| |||||||||||
Sets whether this ViewGroup's drawable states also include
its children's drawable states.
| |||||||||||
Indicates whether this ViewGroup will always try to draw its children using their
drawing cache.
| |||||||||||
Enables or disables the children's drawing cache during a layout animation.
| |||||||||||
By default, children are clipped to their bounds before drawing.
| |||||||||||
By default, children are clipped to the padding of the ViewGroup.
| |||||||||||
Set the descendant focusability of this view group.
| |||||||||||
Sets the layout animation controller used to animate the group's
children after the first layout.
| |||||||||||
Specifies the animation listener to which layout animation events must
be sent.
| |||||||||||
Register a callback to be invoked when a child is added to or removed
from this view.
| |||||||||||
Sets the padding.
| |||||||||||
Indicates what types of drawing caches should be kept in memory after
they have been created.
| |||||||||||
Bring up a context menu for the specified view or its ancestors.
| |||||||||||
Runs the layout animation.
| |||||||||||
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds a view during layout.
| |||||||||||
Adds a view during layout.
| |||||||||||
Subclasses should override this method to set layout animation
parameters on the supplied child.
| |||||||||||
Attaches a view to this view group.
| |||||||||||
Indicates whether the view group has the ability to animate its children
after the first layout.
| |||||||||||
Prevents the specified child to be laid out during the next layout pass.
| |||||||||||
Prints information about this view in the log output, with the tag
VIEW_LOG_TAG.
| |||||||||||
Detaches all views from the parent.
| |||||||||||
Detaches a view from its parent.
| |||||||||||
Detaches a view from its parent.
| |||||||||||
Detaches a range of view from their parent.
| |||||||||||
Called by draw to draw the child views.
| |||||||||||
Perform dispatching of a freeze() to only this view,
not to its children.
| |||||||||||
Called by restoreHierarchyState(SparseArray
| |||||||||||
Called by saveHierarchyState(SparseArray
| |||||||||||
Dispatch setPressed to all of this View's children.
| |||||||||||
Perform dispatching of a thaw() to only this view,
not to its children.
| |||||||||||
Draw one child of this View Group.
| |||||||||||
This function is called whenever the state of the view changes in such
a way that it impacts the state of drawables being shown.
| |||||||||||
Apply the insets for system windows to this view, if the FITS_SYSTEM_WINDOWS flag
is set
| |||||||||||
Returns a set of default layout parameters.
| |||||||||||
Returns a safe set of layout parameters based on the supplied layout params.
| |||||||||||
Returns the index of the child to draw for this iteration.
| |||||||||||
Indicates whether the ViewGroup is currently drawing its children using
their drawing cache.
| |||||||||||
Ask one of the children of this view to measure itself, taking into
account both the MeasureSpec requirements for this view and its padding.
| |||||||||||
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.
| |||||||||||
Ask all of the children of this view to measure themselves, taking into
account both the MeasureSpec requirements for this view and its padding.
| |||||||||||
Invoked by a parent ViewGroup to notify the end of the animation
currently associated with this view.
| |||||||||||
Invoked by a parent ViewGroup to notify the start of the animation
currently associated with this view.
| |||||||||||
Generate the new Drawable state for
this view.
| |||||||||||
Called from layout when this view should
assign a size and position to each of its children.
| |||||||||||
Look for a descendant to call requestFocus() on.
| |||||||||||
Finishes the removal of a detached view.
| |||||||||||
Enables or disables the drawing cache for each child of this view group.
| |||||||||||
Tells the ViewGroup to draw its children using their drawing cache.
| |||||||||||
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
|
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.
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.
We clip to padding when FLAG_CLIP_TO_PADDING and FLAG_PADDING_NOT_NULL are set at the same time.
When set, the drawing method will call getChildDrawingOrder(int, int) to get the index of the child to draw for that iteration.
This view will get focus only if none of its descendants want it.
This view will get focus before any of its descendants.
This view will block any of its descendants from getting focus, even if they are focusable.
Used to indicate that all drawing caches should be kept in memory.
Used to indicate that the animation drawing cache should be kept in memory.
Used to indicate that no drawing cache should be kept in memory.
Used to indicate that the scrolling drawing cache should be kept in memory.
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.
views | Focusable views found so far |
---|---|
direction | The direction of the focus |
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.
Add any touchable views that are descendants of this view (possibly including this view if it is touchable itself) to views.
views | Touchable views found so far |
---|
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.
child | the child view to add |
---|---|
index | the position at which to add the child |
Adds a child view with this ViewGroup's default layout parameters and the specified width and height.
child | the child view to add |
---|
Adds a child view with the specified layout parameters.
child | the child view to add |
---|---|
params | the layout parameters to set on the child |
Adds a child view with the specified layout 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 |
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.
child | the child view to add |
---|
Change the z order of the child so it's on top of all other children
If {link #addStatesFromChildren} is true, refreshes this group's drawable state (to include the states from its children).
child | The child whose drawable state has changed. |
---|
Called when a child of this parent is giving up focus
child | The view that is giving up focus |
---|
Removes any pending animations for views that have been removed. Call this if you don't want animations for exiting views to stack up.
Called when this view wants to give up focus. This will cause onFocusChanged(boolean, int, Rect) to be called.
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.
event | The key event to be dispatched. |
---|
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.
event | The key event to be dispatched. |
---|
Dispatches a key shortcut event.
event | The key event to be dispatched. |
---|
Dispatch setSelected to all of this View's children.
selected | The new selected state |
---|
Pass the touch screen motion event down to the target view, or this view if it is the target.
ev | The motion event to be dispatched. |
---|
Pass a trackball motion event down to the focused view.
event | The motion event to be dispatched. |
---|
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.
focused | The currently focused view. |
---|---|
direction | The direction focus wants to move. One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT. |
Called when the window containing this view gains or loses window focus. ViewGroups should override to route to their children.
hasFocus | True if the window containing this view now has focus, false otherwise. |
---|
Dispatch a window visibility change down the view hierarchy. ViewGroups should override to route to their children.
visibility | The new visibility of the window. |
---|
Find the view in the hierarchy rooted at this view that currently has focus.
Find the nearest view in the specified direction that wants to take focus.
focused | The view that currently has focus |
---|---|
direction | One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT, or 0 for not applicable. |
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.
v | The view that has become newly focusable |
---|
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).
region | The transparent region for this ViewRoot (window). |
---|
Returns a new set of layout parameters based on the supplied attributes set.
attrs | the attributes to build the layout parameters from |
---|
Returns the view at the specified position in the group.
index | the position at which to get the view from |
---|
Returns the number of children in the group.
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.
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 |
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 the focused child of this view, if any. The child may have focus or contain focus.
Returns the layout animation controller used to animate the group's children.
Returns the animation listener to which layout animation events are sent.
Returns an integer indicating what types of drawing caches are kept in memory.
Returns true if this view has or contains focus
Returns true if this view is focusable or if it contains a reachable View for which hasFocusable() returns true. A "reachable hasFocusable()" is a View whose parents do not block descendants focus. Only VISIBLE views are considered focusable.
Returns the position in the group of the specified child view.
child | the view for which to get the position |
---|
Don't call or override this method. It is used for the implementation of the view hierarchy.
child | The child which is dirty |
---|---|
dirty | The area within the child that is invalid |
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.
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 |
Indicates whether this ViewGroup will always try to draw its children using their drawing cache. By default this property is enabled.
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.
Offset a rectangle that is in a descendant's coordinate space into our coordinate space.
descendant | A descendant of this view |
---|---|
rect | A rectangle defined in descendant's coordinate space. |
Offset a rectangle that is in our coordinate space into an ancestor's coordinate space.
descendant | A descendant of this view |
---|---|
rect | A rectangle defined in descendant's coordinate space. |
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:
ev | The motion event being dispatched down the hierarchy. |
---|
Tell view hierarchy that the global view attributes need to be re-evaluated.
child | View whose attributes have changed. |
---|
Call this method to remove all child views from the ViewGroup.
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.
Removes the view at the specified position in the group.
index | the position in the group of the view to remove |
---|
Removes a view during layout. This is useful if in your onLayout() method, you need to remove more views.
view | the view to remove from the group |
---|
Removes the specified range of views from the group.
start | the first position in the group of the range of views to remove |
---|---|
count | the number of views to remove |
Removes a range of views during layout. This is useful if in your onLayout() method, you need to remove more views.
start | the index of the first view to remove from the group |
---|---|
count | the number of views to remove from the group |
Called when a child of this parent wants focus
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 |
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:
child | The direct child making the request. |
---|---|
rectangle | The rectangle in the child's coordinates the child wishes to be on the screen. |
immediate | True to forbid animated or delayed scrolling, false otherwise |
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.
disallowIntercept | True if the child does not want the parent to intercept touch events. |
---|
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 (isFocusable() returns false), or if it is focusable and it is not focusable in touch mode (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 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.
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. |
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.
child | the view requesting the transparent region computation |
---|
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.
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.
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.
always | true to always draw with the drawing cache, false otherwise |
---|
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.
enabled | true to enable the animation cache, false otherwise |
---|
By default, children are clipped to their bounds before drawing. This allows view groups to override this behavior for animations, etc.
clipChildren | true to clip children to their bounds, false otherwise |
---|
By default, children are clipped to the padding of the ViewGroup. This allows view groups to override this behavior
clipToPadding | true to clip children to the padding of the group, false otherwise |
---|
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).
focusability | one of FOCUS_BEFORE_DESCENDANTS, FOCUS_AFTER_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS. |
---|
Sets the layout animation controller used to animate the group's children after the first layout.
controller | the animation controller |
---|
Specifies the animation listener to which layout animation events must be sent. Only onAnimationStart(Animation) and onAnimationEnd(Animation) are invoked.
animationListener | the layout animation listener |
---|
Register a callback to be invoked when a child is added to or removed from this view.
listener | the callback to invoke on hierarchy change |
---|
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 getPaddingLeft(), getPaddingTop(), getPaddingRight() and getPaddingBottom() may be different from the values set in this call.
left | the left padding in pixels |
---|---|
top | the top padding in pixels |
right | the right padding in pixels |
bottom | the bottom padding in pixels |
Indicates what types of drawing caches should be kept in memory after they have been created.
drawingCacheToKeep | one or a combination of PERSISTENT_NO_CACHE, PERSISTENT_ANIMATION_CACHE, PERSISTENT_SCROLLING_CACHE and PERSISTENT_ALL_CACHES |
---|
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, addView(View, android.view.ViewGroup.LayoutParams)) then it should override this and show the context menu.
originalView | The source view where the context menu was first invoked |
---|
Runs the layout animation. Calling this method triggers a relayout of this view group.
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.
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 |
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.
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 |
Subclasses should override this method to set layout animation parameters on the supplied child.
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 |
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.
child | the child to attach |
---|---|
index | the index at which the child should be attached |
params | the layout parameters of the child |
Indicates whether the view group has the ability to animate its children after the first layout.
Prevents the specified child to be laid out during the next layout pass.
child | the child on which to perform the cleanup |
---|
Prints information about this view in the log output, with the tag
VIEW_LOG_TAG. Each line in the output is preceded with an
indentation defined by the depth
.
depth | the indentation level |
---|
Detaches all views from the 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).
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).
child | the child to detach |
---|
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).
index | the index of the child to detach |
---|
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).
start | the first index of the childrend range to detach |
---|---|
count | the number of children to detach |
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).
canvas | the canvas on which to draw the view |
---|
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.
container | the container |
---|
Called by restoreHierarchyState(SparseArray
container | The SparseArray which holds previously saved state. |
---|
Called by saveHierarchyState(SparseArray
container | The SparseArray in which to save the view's state. |
---|
Dispatch setPressed to all of this View's children.
pressed | The new pressed state |
---|
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.
container | the container |
---|
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.
canvas | The canvas on which to draw the child |
---|---|
child | Who to draw |
drawingTime | The time at which draw is occuring |
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.
Apply the insets for system windows to this view, if the FITS_SYSTEM_WINDOWS flag is set
insets | Insets for system windows |
---|
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 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.
p | The layout parameters to convert into a suitable set of layout parameters for this ViewGroup. |
---|
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.
i | The current iteration. |
---|
Indicates whether the ViewGroup is currently drawing its children using their drawing cache.
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.
child | The child to measure |
---|---|
parentWidthMeasureSpec | The width requirements for this view |
parentHeightMeasureSpec | The height requirements for this view |
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.
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) |
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.
widthMeasureSpec | The width requirements for this view |
---|---|
heightMeasureSpec | The height requirements for this 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();
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();
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 getDrawableState().
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. |
---|
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.
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 |
Look for a descendant to call requestFocus() on. Called by requestFocus(int, android.graphics.Rect) when it wants to request focus within its children. Override this to customize how your ViewGroup requests focus within its children.
direction | One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_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. |
Finishes the removal of a detached view. This method will dispatch the detached from window event and notify the hierarchy change listener.
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 |
Enables or disables the drawing cache for each child of this view group.
enabled | true to enable the cache, false to dispose of it |
---|
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.
enabled | true if children should be drawn with their cache, false otherwise |
---|
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. Any subclass overriding getChildStaticTransformation(View, android.view.animation.Transformation) should set this property to true.
enabled | True to enable static transformations on children, false otherwise. |
---|