Android Guides | Samples

Android.Views.ViewGroup Class

Developer Guides

java Example

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RemoteViews;

/**
 * Example of writing a custom layout manager.  This is a fairly full-featured
 * layout manager that is relatively general, handling all layout cases.  You
 * can simplify it for more specific cases.
 */
@RemoteViews.RemoteView
public class CustomLayout extends ViewGroup {
    /** The amount of space used by children in the left gutter. */
    private int mLeftWidth;

    /** The amount of space used by children in the right gutter. */
    private int mRightWidth;

    /** These are used for computing child frames based on their gravity. */
    private final Rect mTmpContainerRect = new Rect();
    private final Rect mTmpChildRect = new Rect();

    public CustomLayout(Context context) {
        super(context);
    }

    public CustomLayout(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public CustomLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    /**
     * Any layout manager that doesn't scroll will want this.
     */
    @Override
    public boolean shouldDelayChildPressedState() {
        return false;
    }

    /**
     * Ask all children to measure themselves and compute the measurement of this
     * layout based on the children.
     */
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int count = getChildCount();

        // These keep track of the space we are using on the left and right for
        // views positioned there; we need member variables so we can also use
        // these for layout later.
        mLeftWidth = 0;
        mRightWidth = 0;

        // Measurement will ultimately be computing these values.
        int maxHeight = 0;
        int maxWidth = 0;
        int childState = 0;

        // Iterate through all children, measuring them and computing our dimensions
        // from their size.
        for (int i = 0; i < count; i++) {
            final View child = getChildAt(i);
            if (child.getVisibility() != GONE) {
                // Measure the child.
                measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);

                // Update our size information based on the layout params.  Children
                // that asked to be positioned on the left or right go in those gutters.
                final LayoutParams lp = (LayoutParams) child.getLayoutParams();
                if (lp.position == LayoutParams.POSITION_LEFT) {
                    mLeftWidth += Math.max(maxWidth,
                            child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin);
                } else if (lp.position == LayoutParams.POSITION_RIGHT) {
                    mRightWidth += Math.max(maxWidth,
                            child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin);
                } else {
                    maxWidth = Math.max(maxWidth,
                            child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin);
                }
                maxHeight = Math.max(maxHeight,
                        child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin);
                childState = combineMeasuredStates(childState, child.getMeasuredState());
            }
        }

        // Total width is the maximum width of all inner children plus the gutters.
        maxWidth += mLeftWidth + mRightWidth;

        // Check against our minimum height and width
        maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
        maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth());

        // Report our final dimensions.
        setMeasuredDimension(resolveSizeAndState(maxWidth, widthMeasureSpec, childState),
                resolveSizeAndState(maxHeight, heightMeasureSpec,
                        childState << MEASURED_HEIGHT_STATE_SHIFT));
    }

    /**
     * Position all children within this layout.
     */
    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        final int count = getChildCount();

        // These are the far left and right edges in which we are performing layout.
        int leftPos = getPaddingLeft();
        int rightPos = right - left - getPaddingRight();

        // This is the middle region inside of the gutter.
        final int middleLeft = leftPos + mLeftWidth;
        final int middleRight = rightPos - mRightWidth;

        // These are the top and bottom edges in which we are performing layout.
        final int parentTop = getPaddingTop();
        final int parentBottom = bottom - top - getPaddingBottom();

        for (int i = 0; i < count; i++) {
            final View child = getChildAt(i);
            if (child.getVisibility() != GONE) {
                final LayoutParams lp = (LayoutParams) child.getLayoutParams();

                final int width = child.getMeasuredWidth();
                final int height = child.getMeasuredHeight();

                // Compute the frame in which we are placing this child.
                if (lp.position == LayoutParams.POSITION_LEFT) {
                    mTmpContainerRect.left = leftPos + lp.leftMargin;
                    mTmpContainerRect.right = leftPos + width + lp.rightMargin;
                    leftPos = mTmpContainerRect.right;
                } else if (lp.position == LayoutParams.POSITION_RIGHT) {
                    mTmpContainerRect.right = rightPos - lp.rightMargin;
                    mTmpContainerRect.left = rightPos - width - lp.leftMargin;
                    rightPos = mTmpContainerRect.left;
                } else {
                    mTmpContainerRect.left = middleLeft + lp.leftMargin;
                    mTmpContainerRect.right = middleRight - lp.rightMargin;
                }
                mTmpContainerRect.top = parentTop + lp.topMargin;
                mTmpContainerRect.bottom = parentBottom - lp.bottomMargin;

                // Use the child's gravity and size to determine its final
                // frame within its container.
                Gravity.apply(lp.gravity, width, height, mTmpContainerRect, mTmpChildRect);

                // Place the child.
                child.layout(mTmpChildRect.left, mTmpChildRect.top,
                        mTmpChildRect.right, mTmpChildRect.bottom);
            }
        }
    }

    // ----------------------------------------------------------------------
    // The rest of the implementation is for custom per-child layout parameters.
    // If you do not need these (for example you are writing a layout manager
    // that does fixed positioning of its children), you can drop all of this.

    @Override
    public LayoutParams generateLayoutParams(AttributeSet attrs) {
        return new CustomLayout.LayoutParams(getContext(), attrs);
    }

    @Override
    protected LayoutParams generateDefaultLayoutParams() {
        return new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    }

    @Override
    protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
        return new LayoutParams(p);
    }

    @Override
    protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
        return p instanceof LayoutParams;
    }

    /**
     * Custom per-child layout information.
     */
    public static class LayoutParams extends MarginLayoutParams {
        /**
         * The gravity to apply with the View to which these layout parameters
         * are associated.
         */
        public int gravity = Gravity.TOP | Gravity.START;

        public static int POSITION_MIDDLE = 0;
        public static int POSITION_LEFT = 1;
        public static int POSITION_RIGHT = 2;

        public int position = POSITION_MIDDLE;

        public LayoutParams(Context c, AttributeSet attrs) {
            super(c, attrs);

            // Pull the layout param values from the layout XML during
            // inflation.  This is not needed if you don't care about
            // changing the layout behavior in XML.
            TypedArray a = c.obtainStyledAttributes(attrs, R.styleable.CustomLayoutLP);
            gravity = a.getInt(R.styleable.CustomLayoutLP_android_layout_gravity, gravity);
            position = a.getInt(R.styleable.CustomLayoutLP_layout_position, position);
            a.recycle();
        }

        public LayoutParams(int width, int height) {
            super(width, height);
        }

        public LayoutParams(ViewGroup.LayoutParams source) {
            super(source);
        }
    }
}

xml Example

<declare-styleable name="CustomLayoutLP">
    <attr name="android:layout_gravity" />
    <attr name="layout_position">
        <enum name="middle" value="0" />
        <enum name="left" value="1" />
        <enum name="right" value="2" />
    </attr>
</declare-styleable>

xml Example

<com.example.android.apis.view.CustomLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res/com.example.android.apis"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <!-- put first view to left. -->
    <TextView
            android:background="@drawable/filled_box"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_position="left"
            android:layout_gravity="fill_vertical|center_horizontal"
            android:text="l1"/>

    <!-- stack second view to left. -->
    <TextView
            android:background="@drawable/filled_box"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_position="left"
            android:layout_gravity="fill_vertical|center_horizontal"
            android:text="l2"/>

    <!-- also put a view on the right. -->
    <TextView
            android:background="@drawable/filled_box"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_position="right"
            android:layout_gravity="fill_vertical|center_horizontal"
            android:text="r1"/>

    <!-- by default views go in the middle; use fill vertical gravity -->
    <TextView
            android:background="@drawable/green"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="fill_vertical|center_horizontal"
            android:text="fill-vert"/>

    <!-- by default views go in the middle; use fill horizontal gravity -->
    <TextView
            android:background="@drawable/green"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|fill_horizontal"
            android:text="fill-horiz"/>

    <!-- by default views go in the middle; use top-left gravity -->
    <TextView
            android:background="@drawable/blue"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top|left"
            android:text="top-left"/>

    <!-- by default views go in the middle; use center gravity -->
    <TextView
            android:background="@drawable/blue"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="center"/>

    <!-- by default views go in the middle; use bottom-right -->
    <TextView
            android:background="@drawable/blue"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|right"
            android:text="bottom-right"/>

</com.example.android.apis.view.CustomLayout>

See Also: ViewGroup

Syntax

[Android.Runtime.Register("android/view/ViewGroup", DoNotGenerateAcw=true)]
public abstract class ViewGroup : View, IViewManager, IViewParent, IDisposable

Remarks

Developer Guides

java Example

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RemoteViews;

/**
 * Example of writing a custom layout manager.  This is a fairly full-featured
 * layout manager that is relatively general, handling all layout cases.  You
 * can simplify it for more specific cases.
 */
@RemoteViews.RemoteView
public class CustomLayout extends ViewGroup {
    /** The amount of space used by children in the left gutter. */
    private int mLeftWidth;

    /** The amount of space used by children in the right gutter. */
    private int mRightWidth;

    /** These are used for computing child frames based on their gravity. */
    private final Rect mTmpContainerRect = new Rect();
    private final Rect mTmpChildRect = new Rect();

    public CustomLayout(Context context) {
        super(context);
    }

    public CustomLayout(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public CustomLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    /**
     * Any layout manager that doesn't scroll will want this.
     */
    @Override
    public boolean shouldDelayChildPressedState() {
        return false;
    }

    /**
     * Ask all children to measure themselves and compute the measurement of this
     * layout based on the children.
     */
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int count = getChildCount();

        // These keep track of the space we are using on the left and right for
        // views positioned there; we need member variables so we can also use
        // these for layout later.
        mLeftWidth = 0;
        mRightWidth = 0;

        // Measurement will ultimately be computing these values.
        int maxHeight = 0;
        int maxWidth = 0;
        int childState = 0;

        // Iterate through all children, measuring them and computing our dimensions
        // from their size.
        for (int i = 0; i < count; i++) {
            final View child = getChildAt(i);
            if (child.getVisibility() != GONE) {
                // Measure the child.
                measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);

                // Update our size information based on the layout params.  Children
                // that asked to be positioned on the left or right go in those gutters.
                final LayoutParams lp = (LayoutParams) child.getLayoutParams();
                if (lp.position == LayoutParams.POSITION_LEFT) {
                    mLeftWidth += Math.max(maxWidth,
                            child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin);
                } else if (lp.position == LayoutParams.POSITION_RIGHT) {
                    mRightWidth += Math.max(maxWidth,
                            child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin);
                } else {
                    maxWidth = Math.max(maxWidth,
                            child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin);
                }
                maxHeight = Math.max(maxHeight,
                        child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin);
                childState = combineMeasuredStates(childState, child.getMeasuredState());
            }
        }

        // Total width is the maximum width of all inner children plus the gutters.
        maxWidth += mLeftWidth + mRightWidth;

        // Check against our minimum height and width
        maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
        maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth());

        // Report our final dimensions.
        setMeasuredDimension(resolveSizeAndState(maxWidth, widthMeasureSpec, childState),
                resolveSizeAndState(maxHeight, heightMeasureSpec,
                        childState << MEASURED_HEIGHT_STATE_SHIFT));
    }

    /**
     * Position all children within this layout.
     */
    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        final int count = getChildCount();

        // These are the far left and right edges in which we are performing layout.
        int leftPos = getPaddingLeft();
        int rightPos = right - left - getPaddingRight();

        // This is the middle region inside of the gutter.
        final int middleLeft = leftPos + mLeftWidth;
        final int middleRight = rightPos - mRightWidth;

        // These are the top and bottom edges in which we are performing layout.
        final int parentTop = getPaddingTop();
        final int parentBottom = bottom - top - getPaddingBottom();

        for (int i = 0; i < count; i++) {
            final View child = getChildAt(i);
            if (child.getVisibility() != GONE) {
                final LayoutParams lp = (LayoutParams) child.getLayoutParams();

                final int width = child.getMeasuredWidth();
                final int height = child.getMeasuredHeight();

                // Compute the frame in which we are placing this child.
                if (lp.position == LayoutParams.POSITION_LEFT) {
                    mTmpContainerRect.left = leftPos + lp.leftMargin;
                    mTmpContainerRect.right = leftPos + width + lp.rightMargin;
                    leftPos = mTmpContainerRect.right;
                } else if (lp.position == LayoutParams.POSITION_RIGHT) {
                    mTmpContainerRect.right = rightPos - lp.rightMargin;
                    mTmpContainerRect.left = rightPos - width - lp.leftMargin;
                    rightPos = mTmpContainerRect.left;
                } else {
                    mTmpContainerRect.left = middleLeft + lp.leftMargin;
                    mTmpContainerRect.right = middleRight - lp.rightMargin;
                }
                mTmpContainerRect.top = parentTop + lp.topMargin;
                mTmpContainerRect.bottom = parentBottom - lp.bottomMargin;

                // Use the child's gravity and size to determine its final
                // frame within its container.
                Gravity.apply(lp.gravity, width, height, mTmpContainerRect, mTmpChildRect);

                // Place the child.
                child.layout(mTmpChildRect.left, mTmpChildRect.top,
                        mTmpChildRect.right, mTmpChildRect.bottom);
            }
        }
    }

    // ----------------------------------------------------------------------
    // The rest of the implementation is for custom per-child layout parameters.
    // If you do not need these (for example you are writing a layout manager
    // that does fixed positioning of its children), you can drop all of this.

    @Override
    public LayoutParams generateLayoutParams(AttributeSet attrs) {
        return new CustomLayout.LayoutParams(getContext(), attrs);
    }

    @Override
    protected LayoutParams generateDefaultLayoutParams() {
        return new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    }

    @Override
    protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
        return new LayoutParams(p);
    }

    @Override
    protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
        return p instanceof LayoutParams;
    }

    /**
     * Custom per-child layout information.
     */
    public static class LayoutParams extends MarginLayoutParams {
        /**
         * The gravity to apply with the View to which these layout parameters
         * are associated.
         */
        public int gravity = Gravity.TOP | Gravity.START;

        public static int POSITION_MIDDLE = 0;
        public static int POSITION_LEFT = 1;
        public static int POSITION_RIGHT = 2;

        public int position = POSITION_MIDDLE;

        public LayoutParams(Context c, AttributeSet attrs) {
            super(c, attrs);

            // Pull the layout param values from the layout XML during
            // inflation.  This is not needed if you don't care about
            // changing the layout behavior in XML.
            TypedArray a = c.obtainStyledAttributes(attrs, R.styleable.CustomLayoutLP);
            gravity = a.getInt(R.styleable.CustomLayoutLP_android_layout_gravity, gravity);
            position = a.getInt(R.styleable.CustomLayoutLP_layout_position, position);
            a.recycle();
        }

        public LayoutParams(int width, int height) {
            super(width, height);
        }

        public LayoutParams(ViewGroup.LayoutParams source) {
            super(source);
        }
    }
}

xml Example

<declare-styleable name="CustomLayoutLP">
    <attr name="android:layout_gravity" />
    <attr name="layout_position">
        <enum name="middle" value="0" />
        <enum name="left" value="1" />
        <enum name="right" value="2" />
    </attr>
</declare-styleable>

xml Example

<com.example.android.apis.view.CustomLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res/com.example.android.apis"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <!-- put first view to left. -->
    <TextView
            android:background="@drawable/filled_box"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_position="left"
            android:layout_gravity="fill_vertical|center_horizontal"
            android:text="l1"/>

    <!-- stack second view to left. -->
    <TextView
            android:background="@drawable/filled_box"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_position="left"
            android:layout_gravity="fill_vertical|center_horizontal"
            android:text="l2"/>

    <!-- also put a view on the right. -->
    <TextView
            android:background="@drawable/filled_box"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_position="right"
            android:layout_gravity="fill_vertical|center_horizontal"
            android:text="r1"/>

    <!-- by default views go in the middle; use fill vertical gravity -->
    <TextView
            android:background="@drawable/green"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="fill_vertical|center_horizontal"
            android:text="fill-vert"/>

    <!-- by default views go in the middle; use fill horizontal gravity -->
    <TextView
            android:background="@drawable/green"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|fill_horizontal"
            android:text="fill-horiz"/>

    <!-- by default views go in the middle; use top-left gravity -->
    <TextView
            android:background="@drawable/blue"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top|left"
            android:text="top-left"/>

    <!-- by default views go in the middle; use center gravity -->
    <TextView
            android:background="@drawable/blue"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="center"/>

    <!-- by default views go in the middle; use bottom-right -->
    <TextView
            android:background="@drawable/blue"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|right"
            android:text="bottom-right"/>

</com.example.android.apis.view.CustomLayout>

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 NoType:android/view/ViewGroup$LayoutParams;Href=../../../reference/android/view/ViewGroup.LayoutParams.html class which serves as the base class for layouts parameters.

Also see NoType:android/view/ViewGroup$LayoutParams;Href=../../../reference/android/view/ViewGroup.LayoutParams.html for layout attributes.

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

Here is a complete implementation of a custom ViewGroup that implements a simple FrameLayout along with the ability to stack children in left and right gutters.

If you are implementing XML layout attributes as shown in the example, this is the corresponding definition for them that would go in res/values/attrs.xml:

Finally the layout manager can be used in an XML layout like so:

[Android Documentation]

Requirements

Namespace: Android.Views
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.Views.ViewGroup are listed below.

See Also: View

Public Constructors

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Fields

Protected Fields

const
ClipToPaddingMaskInt32 (34). We clip to padding when FLAG_CLIP_TO_PADDING and FLAG_PADDING_NOT_NULL are set at the same time.
const
FlagUseChildDrawingOrderInt32 (1024).

Public Properties

AlwaysDrawnWithCacheEnabledBoolean. Indicates whether this ViewGroup will always try to draw its children using their drawing cache.
AnimationCacheEnabledBoolean. Indicates whether the children's drawing cache is used during a layout animation.
[read-only]
ChildCountInt32. Returns the number of children in the group.
[read-only]
ClipChildrenBoolean. Returns whether this group's children are clipped to their bounds before drawing.
[read-only]
ClipToPaddingBoolean. Returns 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.
DescendantFocusabilityDescendantFocusability. Gets the descendant focusability of this view group.
[read-only]
FocusedChildView. Returns the focused child of this view, if any.
LayoutAnimationLayoutAnimationController. Returns the layout animation controller used to animate the group's children.
LayoutAnimationListenerAnimation+IAnimationListener. Returns the animation listener to which layout animation events are sent.
LayoutModeViewLayoutMode. Returns the basis of alignment during layout operations on this ViewGroup: either ViewGroup.LayoutModeClipBounds or ViewGroup.LayoutModeOpticalBounds.
LayoutTransitionLayoutTransition. Gets the LayoutTransition object for this ViewGroup.
MotionEventSplittingEnabledBoolean. Returns true if MotionEvents dispatched to this ViewGroup can be split to multiple children.
[read-only]
NestedScrollAxesScrollAxis. Return the current axes of nested scrolling for this ViewGroup.
PersistentDrawingCachePersistentDrawingCaches. Returns an integer indicating what types of drawing caches are kept in memory.
TouchscreenBlocksFocusBoolean. Check whether this ViewGroup should ignore focus requests for itself and its children.
TransitionGroupBoolean. Returns true if this ViewGroup should be considered as a single entity for removal when executing an Activity transition.

Protected Properties

ChildrenDrawingOrderEnabledBoolean. Indicates whether the ViewGroup is drawing its children in the order defined by ViewGroup.GetChildDrawingOrder(Int32,Int32).
ChildrenDrawnWithCacheEnabledBoolean. Indicates whether the ViewGroup is currently drawing its children using their drawing cache.
[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

AddStatesFromChildren() : Boolean
Returns whether this ViewGroup's drawable states also include its children's drawable states.
AddView(View)
AddView(View, ViewGroup+LayoutParams)
Adds a child view with the specified layout parameters.
AddView(View, Int32)
Adds a child view.
AddView(View, Int32, ViewGroup+LayoutParams)
Adds a child view with the specified layout parameters.
AddView(View, Int32, Int32)
Adds a child view with this ViewGroup's default layout parameters and the specified width and height.
BringChildToFront(View)
Change the z order of the child so it's on top of all other children.
ChildDrawableStateChanged(View)
If ViewGroup.AddStatesFromChildren is true, refreshes this group's drawable state (to include the states from its children).
ChildHasTransientStateChanged(View, Boolean)
Called when a child view has changed whether or not it is tracking transient state.
ClearChildFocus(View)
Called when a child of this parent is giving up focus
ClearDisappearingChildren()
Removes any pending animations for views that have been removed.
DispatchSetActivated(Boolean)
Dispatch setActivated to all of this View's children.
DispatchSetSelected(Boolean)
Dispatch setSelected to all of this View's children.
EndViewTransition(View)
This method should always be called following an earlier call to ViewGroup.StartViewTransition(View).
FocusableViewAvailable(View)
Tells the parent that a new focusable view has become available.
FocusSearch(View, FocusSearchDirection) : View
Find the nearest view in the specified direction that wants to take focus.
GatherTransparentRegion(Region) : Boolean
This is used by the RootView to perform an optimization when the view hierarchy contains one or several SurfaceView.
GenerateLayoutParams(IAttributeSet) : ViewGroup+LayoutParams
Returns a new set of layout parameters based on the supplied attributes set.
GetChildAt(Int32) : View
Returns the view at the specified position in the group.
static
GetChildMeasureSpec(Int32, Int32, Int32) : Int32
Does the hard part of measureChildren: figuring out the MeasureSpec to pass to a particular child.
GetChildVisibleRect(View, Rect, Point) : Boolean
Compute the visible part of a rectangular region defined in terms of a child view's coordinates.
IndexOfChild(View) : Int32
Returns the position in the group of the specified child view.
InvalidateChild(View, Rect)
Don't call or override this method.
InvalidateChildInParent(Int32[], Rect) : IViewParent
Don't call or override this method.
override
Layout(Int32, Int32, Int32, Int32)
Assign a size and position to a view and all of its descendants
NotifySubtreeAccessibilityStateChanged(View, View, ContentChangeTypes)
Notifies a view parent that the accessibility state of one of its descendants has changed and that the structure of the subtree is different.
OffsetDescendantRectToMyCoords(View, Rect)
Offset a rectangle that is in a descendant's coordinate space into our coordinate space.
OffsetRectIntoDescendantCoords(View, Rect)
Offset a rectangle that is in our coordinate space into an ancestor's coordinate space.
OnInterceptHoverEvent(MotionEvent) : Boolean
Implement this method to intercept hover events before they are handled by child views.
OnInterceptTouchEvent(MotionEvent) : Boolean
Implement this method to intercept all touch screen motion events.
OnNestedFling(View, Single, Single, Boolean) : Boolean
Request a fling from a nested scroll.
OnNestedPreFling(View, Single, Single) : Boolean
React to a nested fling before the target view consumes it.
OnNestedPreScroll(View, Int32, Int32, Int32[])
React to a nested scroll in progress before the target view consumes a portion of the scroll.
OnNestedScroll(View, Int32, Int32, Int32, Int32)
React to a nested scroll in progress.
OnNestedScrollAccepted(View, View, ScrollAxis)
React to the successful claiming of a nested scroll operation.
OnRequestSendAccessibilityEvent(View, AccessibilityEvent) : Boolean
Called when a child has requested sending an AccessibilityEvent and gives an opportunity to its parent to augment the event.
OnStartNestedScroll(View, View, ScrollAxis) : Boolean
React to a descendant view initiating a nestable scroll operation, claiming the nested scroll operation if appropriate.
OnStopNestedScroll(View)
React to a nested scroll operation ending.
RecomputeViewAttributes(View)
Tell view hierarchy that the global view attributes need to be re-evaluated.
RemoveAllViews()
Call this method to remove all child views from the ViewGroup.
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.
RemoveView(View)
RemoveViewAt(Int32)
Removes the view at the specified position in the group.
RemoveViewInLayout(View)
Removes a view during layout.
RemoveViews(Int32, Int32)
Removes the specified range of views from the group.
RemoveViewsInLayout(Int32, Int32)
Removes a range of views during layout.
RequestChildFocus(View, View)
Called when a child of this parent wants focus
RequestChildRectangleOnScreen(View, Rect, Boolean) : Boolean
Called when a child of this group wants a particular rectangle to be positioned onto the screen.
RequestDisallowInterceptTouchEvent(Boolean)
Called when a child does not want this parent and its ancestors to intercept touch events with ViewGroup.OnInterceptTouchEvent(MotionEvent).
RequestSendAccessibilityEvent(View, AccessibilityEvent) : Boolean
Called by a child to request from its parent to send an AccessibilityEvent.
RequestTransparentRegion(View)
Called when a child wants the view hierarchy to gather and report transparent regions to the window compositor.
ScheduleLayoutAnimation()
Schedules the layout animation to be played after the next layout pass of this view group.
SetAddStatesFromChildren(Boolean)
Sets whether this ViewGroup's drawable states also include its children's drawable states.
SetClipChildren(Boolean)
By default, children are clipped to their bounds before drawing.
SetClipToPadding(Boolean)
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.
SetOnHierarchyChangeListener(ViewGroup+IOnHierarchyChangeListener)
Register a callback to be invoked when a child is added to or removed from this view.
ShouldDelayChildPressedState() : Boolean
Return true if the pressed state should be delayed for children or descendants of this ViewGroup.
ShowContextMenuForChild(View) : Boolean
Bring up a context menu for the specified view or its ancestors.
StartActionModeForChild(View, ActionMode+ICallback) : ActionMode
Start an action mode for the specified view with the default type ActionMode.TYPE_PRIMARY.
StartLayoutAnimation()
Runs the layout animation.
StartViewTransition(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.
UpdateViewLayout(View, ViewGroup+LayoutParams)

Protected Methods

AddViewInLayout(View, Int32, ViewGroup+LayoutParams) : Boolean
Adds a view during layout.
AddViewInLayout(View, Int32, ViewGroup+LayoutParams, Boolean) : Boolean
Adds a view during layout.
AttachLayoutAnimationParameters(View, ViewGroup+LayoutParams, Int32, Int32)
Subclasses should override this method to set layout animation parameters on the supplied child.
AttachViewToParent(View, Int32, ViewGroup+LayoutParams)
Attaches a view to this view group.
CanAnimate() : Boolean
Indicates whether the view group has the ability to animate its children after the first layout.
CheckLayoutParams(ViewGroup+LayoutParams) : Boolean
CleanupLayoutState(View)
Prevents the specified child to be laid out during the next layout pass.
Debug(Int32)
Prints information about this view in the log output, with the tag View.ViewLogTag.
DetachAllViewsFromParent()
Detaches all views from the parent.
DetachViewFromParent(View)
Detaches a view from its parent.
DetachViewFromParent(Int32)
Detaches a view from its parent.
DetachViewsFromParent(Int32, Int32)
Detaches a range of views from their parents.
DispatchFreezeSelfOnly(SparseArray)
DispatchThawSelfOnly(SparseArray)
DrawChild(Canvas, View, Int64) : Boolean
Draw one child of this View Group.
GenerateDefaultLayoutParams() : ViewGroup+LayoutParams
Returns a set of default layout parameters.
GenerateLayoutParams(ViewGroup+LayoutParams) : ViewGroup+LayoutParams
Returns a safe set of layout parameters based on the supplied layout params.
GetChildDrawingOrder(Int32, Int32) : Int32
Returns the index of the child to draw for this iteration.
GetChildStaticTransformation(View, Transformation) : Boolean
Sets t to be the static transformation of the child, if set, returning a boolean to indicate whether a static transform was set.
MeasureChild(View, Int32, Int32)
Ask one of the children of this view to measure itself, taking into account both the MeasureSpec requirements for this view and its padding.
MeasureChildren(Int32, Int32)
Ask all of the children of this view to measure themselves, taking into account both the MeasureSpec requirements for this view and its padding.
MeasureChildWithMargins(View, Int32, Int32, Int32, Int32)
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.
abstract
OnLayout(Boolean, Int32, Int32, Int32, Int32)
Called from layout when this view should assign a size and position to each of its children.
OnRequestFocusInDescendants(Int32, Rect) : Boolean
Look for a descendant to call View.RequestFocus on.
RemoveDetachedView(View, Boolean)
Finishes the removal of a detached view.
ResetResolvedLayoutDirection()
ResetResolvedTextDirection()
SetChildrenDrawingCacheEnabled(Boolean)
Enables or disables the drawing cache for each child of this view group.
SetStaticTransformationsEnabled(Boolean)
When this property is set to true, this ViewGroup supports static transformations on children; this causes ViewGroup.GetChildStaticTransformation(View,Transformation) to be invoked when a child is drawn.

Public Events