Added in API level 1

FrameLayout


open class FrameLayout : ViewGroup
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ android.widget.FrameLayout

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). Views that are android.view.View#GONE are used for sizing only if setConsiderGoneChildrenWhenMeasuring() is set to true.

Summary

Nested classes
open

Per-child layout information for layouts that support margins.

XML attributes
android:measureAllChildren Determines whether to measure all children or just those in the VISIBLE or INVISIBLE state when measuring.
Inherited XML attributes
Inherited constants
Public constructors
FrameLayout(context: Context)

FrameLayout(context: Context, attrs: AttributeSet?)

FrameLayout(context: Context, attrs: AttributeSet?, defStyleAttr: Int)

FrameLayout(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int)

Public methods
open FrameLayout.LayoutParams!

open CharSequence!

open Boolean

Determines whether all children, or just those in the VISIBLE or INVISIBLE state, are considered when measuring.

open Boolean

Determines whether all children, or just those in the VISIBLE or INVISIBLE state, are considered when measuring.

open Unit
setForegroundGravity(foregroundGravity: Int)

Describes how the foreground is positioned.

open Unit

Sets whether to consider all children, or just those in the VISIBLE or INVISIBLE state, when measuring.

open Boolean

Protected methods
open Boolean

open FrameLayout.LayoutParams!

Returns a set of layout parameters with a width of android.view.ViewGroup.LayoutParams#MATCH_PARENT, and a height of android.view.ViewGroup.LayoutParams#MATCH_PARENT.

open ViewGroup.LayoutParams!

open Unit
onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int)

open Unit
onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int)

Inherited functions
Inherited properties

XML attributes

android:measureAllChildren

android:measureAllChildren
Determines whether to measure all children or just those in the VISIBLE or INVISIBLE state when measuring. Defaults to false.

May be a boolean value, such as "true" or "false".

Public constructors

FrameLayout

Added in API level 1
FrameLayout(context: Context)
Parameters
context Context: This value cannot be null.

FrameLayout

Added in API level 1
FrameLayout(
    context: Context,
    attrs: AttributeSet?)
Parameters
context Context: This value cannot be null.
attrs AttributeSet?: This value may be null.

FrameLayout

Added in API level 1
FrameLayout(
    context: Context,
    attrs: AttributeSet?,
    defStyleAttr: Int)
Parameters
context Context: This value cannot be null.
attrs AttributeSet?: This value may be null.

FrameLayout

Added in API level 21
FrameLayout(
    context: Context,
    attrs: AttributeSet?,
    defStyleAttr: Int,
    defStyleRes: Int)
Parameters
context Context: This value cannot be null.
attrs AttributeSet?: This value may be null.

Public methods

generateLayoutParams

Added in API level 1
open fun generateLayoutParams(attrs: AttributeSet!): FrameLayout.LayoutParams!
Parameters
attrs AttributeSet!: the attributes to build the layout parameters from
Return
FrameLayout.LayoutParams! an instance of android.view.ViewGroup.LayoutParams or one of its descendants

getAccessibilityClassName

Added in API level 23
open fun getAccessibilityClassName(): CharSequence!

getConsiderGoneChildrenWhenMeasuring

Added in API level 1
Deprecated in API level 15
open fun getConsiderGoneChildrenWhenMeasuring(): Boolean

Deprecated: This method is deprecated in favor of getMeasureAllChildren(), which was renamed for consistency with setMeasureAllChildren().

Determines whether all children, or just those in the VISIBLE or INVISIBLE state, are considered when measuring.

Return
Boolean Whether all children are considered when measuring.

getMeasureAllChildren

Added in API level 14
open fun getMeasureAllChildren(): Boolean

Determines whether all children, or just those in the VISIBLE or INVISIBLE state, are considered when measuring.

Return
Boolean Whether all children are considered when measuring.

setForegroundGravity

Added in API level 1
open fun setForegroundGravity(foregroundGravity: Int): Unit

Describes how the foreground is positioned. Defaults to START and TOP.

Parameters
gravity see android.view.Gravity
foregroundGravity Int: See android.view.Gravity

setMeasureAllChildren

Added in API level 1
open fun setMeasureAllChildren(measureAll: Boolean): Unit

Sets whether to consider all children, or just those in the VISIBLE or INVISIBLE state, when measuring. Defaults to false.

Parameters
measureAll Boolean: true to consider children marked GONE, false otherwise. Default value is false.

shouldDelayChildPressedState

Added in API level 14
open fun shouldDelayChildPressedState(): Boolean

Protected methods

checkLayoutParams

Added in API level 1
protected open fun checkLayoutParams(p: ViewGroup.LayoutParams!): Boolean

generateDefaultLayoutParams

Added in API level 1
protected open fun generateDefaultLayoutParams(): FrameLayout.LayoutParams!

Returns a set of layout parameters with a width of android.view.ViewGroup.LayoutParams#MATCH_PARENT, and a height of android.view.ViewGroup.LayoutParams#MATCH_PARENT.

Return
FrameLayout.LayoutParams! a set of default layout parameters or null

generateLayoutParams

Added in API level 1
protected open fun generateLayoutParams(lp: ViewGroup.LayoutParams!): ViewGroup.LayoutParams!
Parameters
p The layout parameters to convert into a suitable set of layout parameters for this ViewGroup.
Return
ViewGroup.LayoutParams! an instance of android.view.ViewGroup.LayoutParams or one of its descendants

onLayout

Added in API level 1
protected open fun onLayout(
    changed: Boolean,
    left: Int,
    top: Int,
    right: Int,
    bottom: Int
): Unit
Parameters
changed Boolean: This is a new size or position for this view
left Int: Left position, relative to parent
top Int: Top position, relative to parent
right Int: Right position, relative to parent
bottom Int: Bottom position, relative to parent

onMeasure

Added in API level 1
protected open fun onMeasure(
    widthMeasureSpec: Int,
    heightMeasureSpec: Int
): Unit
Parameters
widthMeasureSpec Int: horizontal space requirements as imposed by the parent. The requirements are encoded with android.view.View.MeasureSpec.
heightMeasureSpec Int: vertical space requirements as imposed by the parent. The requirements are encoded with android.view.View.MeasureSpec.