ViewGroup
declare class ViewGroup extends View implements ViewParent {}
A 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 class which serves as the base class for layouts parameters.
ViewGroup ViewGroup.LayoutParams
Also see for layout attributes. LayoutParams
Attribute
clipToPadding
<FrameLayout clipToPadding="true">
<View layout_width="30px"
layout_height="30px"
background="#000000" />
</FrameLayout>
Description
Defines whether the ViewGroup will clip its children and resize (but not clip) any EdgeEffect to its padding, if padding is not zero. This property is set to true by default.
May be a boolean value, such as "true" or "false".
clipChildren
<FrameLayout clipChildren="true">
<View layout_width="30px"
layout_height="30px"
background="#000000" />
</FrameLayout>
Description
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.
May be a boolean value, such as "true" or "false".
Static Method
getChildMeasureSpec
Signature
declare class ViewGroup {
getChildMeasureSpec(spec: number, padding: number, childDimension: number): number
}
Description
Does the hard part of measureChildren: figuring out the MeasureSpec to pass to a particular child.
Instance Method
constructor
Signature
declare class ViewGroup {
constructor(context: Context, attr: AttributeSet);
}
Description
Create a new viewGroup.
removeView
Signature
declare class ViewGroup {
removeView(view: View): void;
}
Description
Removes the view
note: do not invoke this method from or any related method.View.draw(Canvas)
View.onDraw(Canvas)
removeAllViews
Signature
declare class ViewGroup {
removeAllViews(): void;
}
Description
Call this method to remove all child views from the ViewGroup.
removeViewAt
Signature
declare class ViewGroup {
removeViewAt(index: number): void;
}
Description
Removes the view at the specified position in the group.
note: do not invoke this method from or any related method.View.draw(Canvas)
View.onDraw(Canvas)
indexOfChild
Signature
declare class ViewGroup {
indexOfChild(child: View): number;
}
Description
Returns the position in the group of the specified child view.
addView
Signature
declare class ViewGroup {
addView(child: View): View;
addView(child: View, index: number): View;
}
Description
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.
addView
Signature
declare class ViewGroup {
addView(child: View, index: number, params: ViewGroup.LayoutParams): View
}
Description
Adds a child view with the specified layout parameters.
generateLayoutParams
Signature
declare class ViewGroup {
generateLayoutParams(attribute: AttributeSet): ViewGroup.LayoutParams
}
Description
Returns a new set of layout parameters based on the supplied attributes set.
generateLayoutParams
Signature
declare class ViewGroup {
generateLayoutParams(params: ViewGroup.LayoutParams): ViewGroup.LayoutParams
}
Description
Returns a safe set of layout parameters based on the supplied layout params.
getParent
Signature
declare class ViewGroup {
getParent(): ViewParent
}
Description
Get Parent view.
getChildCount
Signature
declare class ViewGroup {
getChildCount(): number;
}
Description
Returns the number of children in the group.
getChildDrawingOrder
Signature
declare class ViewGroup {
getChildDrawingOrder(childCount: number, i: number): number;
}
Description
Converts drawing order position to container position.
getChildAt
Signature
declare class ViewGroup {
getChildAt(index: number): View
}
Description
Returns the view at the specified position in the group.
getClipToPadding
Signature
declare class ViewGroup {
getClipToPadding():boolean
}
Description
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.
setClipChildren
Signature
declare class ViewGroup {
setClipChildren(clipChildren: boolean): void
}
Description
By default, children are clipped to their bounds before drawing.
setClipToPadding
Signature
declare class ViewGroup {
setClipToPadding(clipToPadding: boolean): void
}
Description
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.
setChildrenDrawingOrderEnabled
Signature
declare class ViewGroup {
setChildrenDrawingOrderEnabled(enabled: boolean): void;
}
Description
Tells the ViewGroup whether to draw its children in the order defined by the methodgetChildDrawingOrder(number, number)
.
ViewGroup.LayoutParams
LayoutParams are used by views to tell their parents how they want to be laid out.
There are subclasses of LayoutParams for different subclasses of ViewGroup. For example, AbsoluteLayout has its own subclass of LayoutParams which adds an X and Y value.
declare class LayoutParams {}
Attribute
layout_width
<FrameLayout>
<View layout_width="10px" />
</FrameLayout>
Description
Specifies the basic width of the view.
layout_height
<FrameLayout>
<View layout_height="10px" />
</FrameLayout>
Description
Specifies the basic height of the view.
Static Property
MATCH_PARENT
Type
declare class View {
static MATCH_PARENT: number;
}
Description
Special value for the height or width requested by a View. MATCH_PARENT means that the view wants to be as big as its parent, minus the parent's padding, if any.
WRAP_CONTENT
Type
declare class View {
static WRAP_CONTENT: number;
}
Description
Special value for the height or width requested by a View. WRAP_CONTENT means that the view wants to be just large enough to fit its own internal content, taking its own padding into account.
Instance Method
getWidth
Signature
declare interface LayoutParams {
getWidth(): number
}
Description
Get Specifies the basic width of the view.
getHeight
Signature
declare interface LayoutParams {
getHeight(): number
}
Description
Get Specifies the basic height of the view.
setWidth
Signature
declare interface LayoutParams {
setWidth(width: number): void
}
Description
Set Specifies the basic width of the view.
setHeight
Signature
declare interface LayoutParams {
setHeight(height: number): void
}
Description
Set Specifies the basic height of the view.
ViewGroup.MarginLayoutParams
declare class MarginLayoutParams extends LayoutParams {}
Per-child layout information for layouts that support margins.
Attribute
layout_margin
<FrameLayout>
<View layout_margin="10px" />
</FrameLayout>
Description
Specifies extra space on the left, top, right and bottom sides of this view.
layout_marginTop
<FrameLayout>
<View layout_marginTop="10px" />
</FrameLayout>
Description
Specifies extra space on the top side of this view.
layout_marginLeft
<FrameLayout>
<View layout_marginLeft="10px" />
</FrameLayout>
Description
Specifies extra space on the left side of this view.
layout_marginRight
<FrameLayout>
<View layout_marginRight="10px" />
</FrameLayout>
Description
Specifies extra space on the right side of this view.
layout_marginBottom
<FrameLayout>
<View layout_marginBottom="10px" />
</FrameLayout>
Description
Specifies extra space on the bottom side of this view.
Instance Method
setLeftMargin
Signature
declare class MarginLayoutParams {
setLeftMargin(left: number): number;
}
Description
Set Specifies the basic left margin of the view.
setTopMargin
Signature
declare class MarginLayoutParams {
setTopMargin(top: number): number;
}
Description
Set Specifies the basic top margin of the view.
setRightMargin
Signature
declare class MarginLayoutParams {
setRightMargin(right: number): void;
}
Description
Set Specifies the basic right margin of the view.
setBottomMargin
Signature
declare class MarginLayoutParams {
setBottomMargin(bottom: number): void;
}
Description
Set Specifies the basic bottom margin of the view.
setMargins
Signature
declare class MarginLayoutParams {
setMargins(left: number, top: number, right: number, bottom: number): number;
}
Description
Set Specifies the basic all margin of the view.
getLeftMargin
Signature
declare class MarginLayoutParams {
getLeftMargin(): number;
}
Description
Get Specifies the basic left margin of the view.
getTopMargin
Signature
declare class MarginLayoutParams {
getTopMargin(): number;
}
Description
Get Specifies the basic top margin of the view.
getRightMargin
Signature
declare class MarginLayoutParams {
getRightMargin(): number
}
Description
Get Specifies the basic right margin of the view.
getBottomMargin
Signature
declare class MarginLayoutParams {
getBottomMargin(): number;
}
Description
Get Specifies the basic bottom margin of the view.