Added in API level 1

RelativeLayout


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

A Layout where the positions of the children can be described in relation to each other or to the parent.

Note that you cannot have a circular dependency between the size of the RelativeLayout and the position of its children. For example, you cannot have a RelativeLayout whose height is set to WRAP_CONTENT and a child set to ALIGN_PARENT_BOTTOM.

Note: In platform version 17 and lower, RelativeLayout was affected by a measurement bug that could cause child views to be measured with incorrect MeasureSpec values. (See MeasureSpec.makeMeasureSpec for more details.) This was triggered when a RelativeLayout container was placed in a scrolling container, such as a ScrollView or HorizontalScrollView. If a custom view not equipped to properly measure with the MeasureSpec mode UNSPECIFIED was placed in a RelativeLayout, this would silently work anyway as RelativeLayout would pass a very large AT_MOST MeasureSpec instead.

This behavior has been preserved for apps that set android:targetSdkVersion="17" or older in their manifest's uses-sdk tag for compatibility. Apps targeting SDK version 18 or newer will receive the correct behavior.

See the Relative Layout guide.

Also see RelativeLayout.LayoutParams for layout attributes

Summary

Nested classes
open

Specifies how a view is positioned within a RelativeLayout.

XML attributes
android:gravity Specifies how an object should position its content, on both the X and Y axes, within its own bounds.
android:ignoreGravity Indicates what view should not be affected by gravity.
Inherited XML attributes
Constants
static Int

Rule that aligns a child's bottom edge with another child's top edge.

static Int

Rule that aligns a child's baseline with another child's baseline.

static Int

Rule that aligns a child's bottom edge with another child's bottom edge.

static Int

Rule that aligns a child's end edge with another child's end edge.

static Int

Rule that aligns a child's left edge with another child's left edge.

static Int

Rule that aligns the child's bottom edge with its RelativeLayout parent's bottom edge.

static Int

Rule that aligns the child's end edge with its RelativeLayout parent's end edge.

static Int

Rule that aligns the child's left edge with its RelativeLayout parent's left edge.

static Int

Rule that aligns the child's right edge with its RelativeLayout parent's right edge.

static Int

Rule that aligns the child's start edge with its RelativeLayout parent's start edge.

static Int

Rule that aligns the child's top edge with its RelativeLayout parent's top edge.

static Int

Rule that aligns a child's right edge with another child's right edge.

static Int

Rule that aligns a child's start edge with another child's start edge.

static Int

Rule that aligns a child's top edge with another child's top edge.

static Int

Rule that aligns a child's top edge with another child's bottom edge.

static Int

Rule that centers the child horizontally with respect to the bounds of its RelativeLayout parent.

static Int

Rule that centers the child with respect to the bounds of its RelativeLayout parent.

static Int

Rule that centers the child vertically with respect to the bounds of its RelativeLayout parent.

static Int

Rule that aligns a child's start edge with another child's end edge.

static Int

Rule that aligns a child's right edge with another child's left edge.

static Int

Rule that aligns a child's left edge with another child's right edge.

static Int

Rule that aligns a child's end edge with another child's start edge.

static Int

Inherited constants
Public constructors

RelativeLayout(context: Context!, attrs: AttributeSet!)

RelativeLayout(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

RelativeLayout(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

Public methods
open RelativeLayout.LayoutParams!

open CharSequence!

open Int

open Int

Describes how the child views are positioned.

open Int

Get the id of the View to be ignored by gravity

open Unit

open Unit
setGravity(gravity: Int)

Describes how the child views are positioned.

open Unit
setHorizontalGravity(horizontalGravity: Int)

open Unit

Defines which View is ignored when the gravity is applied.

open Unit
setVerticalGravity(verticalGravity: Int)

open Boolean

Protected methods
open Boolean

open ViewGroup.LayoutParams!

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

open ViewGroup.LayoutParams!

open Unit
onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int)

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

Inherited functions