Java android.view ViewGroup fields, constructors, methods, implement or subclass

Example usage for Java android.view ViewGroup fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for android.view ViewGroup.

The text is from its open source code.

Subclass

android.view.ViewGroup has subclasses.
Click this link to see all its subclasses.

Field

intFOCUS_BEFORE_DESCENDANTS
This view will get focus before any of its descendants.
intFOCUS_AFTER_DESCENDANTS
This view will get focus only if none of its descendants want it.
intFOCUS_BLOCK_DESCENDANTS
This view will block any of its descendants from getting focus, even if they are focusable.
intPERSISTENT_ANIMATION_CACHE
Used to indicate that the animation drawing cache should be kept in memory.
intPERSISTENT_SCROLLING_CACHE
Used to indicate that the scrolling drawing cache should be kept in memory.
intPERSISTENT_ALL_CACHES
Used to indicate that all drawing caches should be kept in memory.

Constructor

Method

voidaddOnAttachStateChangeListener(OnAttachStateChangeListener listener)
Add a listener for attach state changes.
voidaddView(View child)

Adds a child view.

voidaddView(View child, int width, int height)
Adds a child view with this ViewGroup's default layout parameters and the specified width and height.
voidaddView(View child, int index, LayoutParams params)
Adds a child view with the specified layout parameters.
voidaddView(View child, int index)
Adds a child view.
voidaddView(View child, LayoutParams params)
Adds a child view with the specified layout parameters.
ViewPropertyAnimatoranimate()
This method returns a ViewPropertyAnimator object, which can be used to animate specific properties on this View.
voidbringChildToFront(View child)
voidbringToFront()
Change the view's z order in the tree, so it's on top of other sibling views.
voidbuildDrawingCache()

Calling this method is equivalent to calling buildDrawingCache(false).

voiddestroyDrawingCache()

Frees the resources used by the drawing cache.

booleandispatchTouchEvent(MotionEvent ev)
voidendViewTransition(View view)
This method should always be called following an earlier call to #startViewTransition(View) .
TfindViewById(@IdRes int id)
Finds the first descendant view with the given ID, the view itself if the ID matches #getId() , or null if the ID is invalid (< 0) or there is no matching view in the hierarchy.
voidfindViewsWithText(ArrayList outViews, CharSequence text, int flags)
TfindViewWithTag(Object tag)
Look for a child view with the given tag.
floatgetAlpha()
The opacity of the view.
DrawablegetBackground()
Gets the background drawable
intgetBottom()
Bottom position of this view relative to its parent.
ViewgetChildAt(int index)
Returns the view at the specified position in the group.
intgetChildCount()
Returns the number of children in the group.
intgetChildMeasureSpec(int spec, int padding, int childDimension)
Does the hard part of measureChildren: figuring out the MeasureSpec to pass to a particular child.
ClassgetClass()
Returns the runtime class of this Object .
booleangetClipChildren()
Returns whether this group's children are clipped to their bounds before drawing.
ContextgetContext()
Returns the context the view is running in, through which it can access the current theme, resources, etc.
BitmapgetDrawingCache()

Calling this method is equivalent to calling getDrawingCache(false).

BitmapgetDrawingCache(boolean autoScale)

Returns the bitmap in which this view drawing is cached.

ArrayListgetFocusables(@FocusDirection int direction)
Find and return all focusable views that are descendants of this view, possibly including this view if it is focusable itself.
intgetHeight()
Return the height of your view.
intgetId()
Returns this view's identifier.
ViewGroup.LayoutParamsgetLayoutParams()
Get the LayoutParams associated with this view.
LayoutTransitiongetLayoutTransition()
Gets the LayoutTransition object for this ViewGroup.
intgetLeft()
Left position of this view relative to its parent.
voidgetLocationInWindow(@Size(2) int[] outLocation)

Computes the coordinates of this view in its window.

voidgetLocationOnScreen(@Size(2) int[] outLocation)

Computes the coordinates of this view on the screen.

intgetMeasuredHeight()
Like #getMeasuredHeightAndState() , but only returns the raw height component (that is the result is masked by #MEASURED_SIZE_MASK ).
intgetMeasuredWidth()
Like #getMeasuredWidthAndState() , but only returns the raw width component (that is the result is masked by #MEASURED_SIZE_MASK ).
intgetMinimumHeight()
Returns the minimum height of the view.
ViewGroupOverlaygetOverlay()
Returns the ViewGroupOverlay for this view group, creating it if it does not yet exist.
intgetPaddingBottom()
Returns the bottom padding of this view.
intgetPaddingLeft()
Returns the left padding of this view.
intgetPaddingRight()
Returns the right padding of this view.
intgetPaddingTop()
Returns the top padding of this view.
ViewParentgetParent()
Gets the parent of this view.
ResourcesgetResources()
Returns the resources associated with this view.
intgetRight()
Right position of this view relative to its parent.
floatgetScaleX()
The amount that the view is scaled in x around the pivot point, as a proportion of the view's unscaled width.
intgetScrollX()
Return the scrolled left position of this view.
intgetScrollY()
Return the scrolled top position of this view.
ObjectgetTag()
Returns this view's tag.
ObjectgetTag(int key)
Returns the tag associated with this view and the specified key.
intgetTop()
Top position of this view relative to its parent.
ArrayListgetTouchables()
Find and return all touchable views that are descendants of this view, possibly including this view if it is touchable itself.
floatgetTranslationX()
The horizontal location of this view relative to its #getLeft() left position.
floatgetTranslationY()
The vertical location of this view relative to its #getTop() top position.
ViewTreeObservergetViewTreeObserver()
Returns the ViewTreeObserver for this view's hierarchy.
intgetVisibility()
Returns the visibility status for this view.
intgetWidth()
Return the width of your view.
voidgetWindowVisibleDisplayFrame(Rect outRect)
Retrieve the overall visible display size in which the window this view is attached to has been positioned in.
booleanhasFocus()
Returns true if this view has or contains focus
intindexOfChild(View child)
Returns the position in the group of the specified child view.
voidinvalidate()
Invalidate the whole view.
booleanisLaidOut()
Returns true if this view has been through at least one layout since it was last attached to or detached from a window.
booleanisSelected()
Indicates the selection state of this view.
booleanisShown()
Returns the visibility of this view and all of its ancestors
voidlayout(int l, int t, int r, int b)
voidmeasure(int widthMeasureSpec, int heightMeasureSpec)

This is called to find out how big a view should be.

voidoffsetDescendantRectToMyCoords(View descendant, Rect rect)
Offset a rectangle that is in a descendant's coordinate space into our coordinate space.
booleanonInterceptTouchEvent(MotionEvent ev)
Implement this method to intercept all touch screen motion events.
booleanonTouchEvent(MotionEvent event)
Implement this method to handle touch screen motion events.
booleanpost(Runnable action)

Causes the Runnable to be added to the message queue.

booleanpostDelayed(Runnable action, long delayMillis)

Causes the Runnable to be added to the message queue, to be run after the specified amount of time elapses.

voidpostOnAnimationDelayed(Runnable action, long delayMillis)

Causes the Runnable to execute on the next animation time step, after the specified amount of time elapses.

voidremoveAllViews()
Call this method to remove all child views from the ViewGroup.
voidremoveAllViewsInLayout()
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.
voidremoveView(View view)

Note: do not invoke this method from #draw(android.graphics.Canvas) , #onDraw(android.graphics.Canvas) , #dispatchDraw(android.graphics.Canvas) or any related method.

voidremoveViewAt(int index)
Removes the view at the specified position in the group.
voidremoveViewInLayout(View view)
Removes a view during layout.
voidremoveViews(int start, int count)
Removes the specified range of views from the group.
voidrequestChildFocus(View child, View focused)
booleanrequestFocus()
Call this to try to give focus to a specific view or to one of its descendants.
voidrequestLayout()
Call this when something has changed which has invalidated the layout of this view.
booleanrequestSendAccessibilityEvent(View child, AccessibilityEvent event)
voidrequestTransparentRegion(View child)
voidsetAccessibilityDelegate(@Nullable AccessibilityDelegate delegate)
Sets a delegate for implementing accessibility support via composition (as opposed to inheritance).
voidsetActivated(boolean activated)
Changes the activated state of this view.
voidsetAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha)
Sets the opacity of the view to a value from 0 to 1, where 0 means the view is completely transparent and 1 means the view is completely opaque.
voidsetAnimation(Animation animation)
Sets the next animation to play for this view.
voidsetAnimationCacheEnabled(boolean enabled)
Enables or disables the children's drawing cache during a layout animation.
voidsetBackground(Drawable background)
Set the background to a given Drawable, or remove the background.
voidsetBackgroundColor(@ColorInt int color)
Sets the background color for this view.
voidsetBackgroundDrawable(Drawable background)
voidsetBackgroundResource(@DrawableRes int resid)
Set the background to a given resource.
voidsetClickable(boolean clickable)
Enables or disables click events for this view.
voidsetClipChildren(boolean clipChildren)
By default, children are clipped to their bounds before drawing.
voidsetClipToPadding(boolean clipToPadding)
Sets whether this ViewGroup will clip its children to its padding and resize (but not clip) any EdgeEffect to the padded region, if padding is present.
voidsetContentDescription(CharSequence contentDescription)
Sets the View 's content description.
voidsetDescendantFocusability(int focusability)
Set the descendant focusability of this view group.
voidsetDrawingCacheEnabled(boolean enabled)

Enables or disables the drawing cache.

voidsetDrawingCacheQuality(@DrawingCacheQuality int quality)
Set the drawing cache quality of this view.
voidsetElevation(float elevation)
Sets the base elevation of this view, in pixels.
voidsetEnabled(boolean enabled)
Set the enabled state of this view.
voidsetFitsSystemWindows(boolean fitSystemWindows)
Sets whether or not this view should account for system screen decorations such as the status bar and inset its content; that is, controlling whether the default implementation of #fitSystemWindows(Rect) will be executed.
voidsetFocusable(boolean focusable)
Set whether this view can receive the focus.
voidsetFocusableInTouchMode(boolean focusableInTouchMode)
Set whether this view can receive focus while in touch mode.
voidsetForeground(Drawable foreground)
Supply a Drawable that is to be rendered on top of all of the content in the view.
voidsetId(@IdRes int id)
Sets the identifier for this view.
voidsetKeepScreenOn(boolean keepScreenOn)
Controls whether the screen should remain on, modifying the value of #KEEP_SCREEN_ON .
voidsetLayoutAnimation(LayoutAnimationController controller)
Sets the layout animation controller used to animate the group's children after the first layout.
voidsetLayoutAnimationListener(Animation.AnimationListener animationListener)
Specifies the animation listener to which layout animation events must be sent.
voidsetLayoutParams(ViewGroup.LayoutParams params)
Set the layout parameters associated with this view.
voidsetLayoutTransition(LayoutTransition transition)
Sets the LayoutTransition object for this ViewGroup.
voidsetMotionEventSplittingEnabled(boolean split)
Enable or disable the splitting of MotionEvents to multiple children during touch event dispatch.
voidsetOnClickListener(@Nullable OnClickListener l)
Register a callback to be invoked when this view is clicked.
voidsetOnHierarchyChangeListener(OnHierarchyChangeListener listener)
Register a callback to be invoked when a child is added to or removed from this view.
voidsetOnLongClickListener(@Nullable OnLongClickListener l)
Register a callback to be invoked when this view is clicked and held.
voidsetOnSystemUiVisibilityChangeListener(OnSystemUiVisibilityChangeListener l)
Set a listener to receive callbacks when the visibility of the system bar changes.
voidsetOnTouchListener(OnTouchListener l)
Register a callback to be invoked when a touch event is sent to this view.
voidsetPadding(int left, int top, int right, int bottom)
Sets the padding.
voidsetPressed(boolean pressed)
Sets the pressed state for this view.
voidsetScrollY(int value)
Set the vertical scrolled position of your view.
voidsetSelected(boolean selected)
Changes the selection state of this view.
voidsetTag(int key, final Object tag)
Sets a tag associated with this view and a key.
voidsetTag(final Object tag)
Sets the tag associated with this view.
voidsetTranslationY(float translationY)
Sets the vertical location of this view relative to its #getTop() top position.
voidsetVisibility(@Visibility int visibility)
Set the visibility state of this view.
voidsetWillNotDraw(boolean willNotDraw)
If this view doesn't do any drawing on its own, set this flag to allow further optimizations.
voidstartAnimation(Animation animation)
Start the specified animation now.
voidstartViewTransition(View view)
This method tells the ViewGroup that the given View object, which should have this ViewGroup as its parent, should be kept around (re-displayed when the ViewGroup draws its children) even if it is removed from its parent.