Skip to main content

FrameLayout

declare class FrameLayout extends ViewGroup {}

FrameLayout is designed to block out an area on the screen to display a single item. Generally, FrameLayout should be used to hold a single child view, because it can be difficult to organize child views in a way that's scalable to different screen sizes without the children overlapping each other. You can, however, add multiple children to a FrameLayout and control their position within the FrameLayout by assigning gravity to each child, using the android:layout_gravity attribute.

Child views are drawn in a stack, with the most recently added child on top. The size of the FrameLayout is the size of its largest child (plus padding), visible or not (if the FrameLayout's parent permits).

Attribute

measureAllChildren

<FrameLayout measureAllChildren="true">
...
</FrameLayout>
  • Description

    Determines whether to measure all children or just those in the VISIBLE or INVISIBLE state when measuring.

FrameLayout.LayoutParams

Per-child layout information for layouts that support margins.

declare class LayoutParams extends ViewGroup.MarginLayoutParams {}

Attribute

layout_gravity

<FrameLayout>
<View layout_gravity="center"
layout_width="10px"
layout_height="10px"
background="#000000" />
</FrameLayout>
  • Description

    Standard gravity constant that a child supplies to its parent.
    center_vertical center_horizontal none topbottom left right center fill fill_vertical fill_horizontal axis_clip clip_vertical clip_horizontal.