# RelativeLayout.LayoutParams

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# LayoutParams

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams "View this page in Java")  

```
open class LayoutParams : ViewGroup.MarginLayoutParams
```

|---|---|---|------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                 ||||
| ↳ | [android.view.ViewGroup.LayoutParams](https://developer.android.com/reference/kotlin/android/view/ViewGroup.LayoutParams.html#)                |||
|   | ↳ | [android.view.ViewGroup.MarginLayoutParams](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#) ||
|   |   | ↳ | [android.widget.RelativeLayout.LayoutParams](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#) |

Specifies how a view is positioned within a[RelativeLayout](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout). The relative layout containing the view uses the value of these layout parameters to determine where to position the view on the screen. If the view is not contained within a relative layout, these attributes are ignored. See the[Relative Layout](https://developer.android.com/guide/topics/ui/layout/relative.html)guide for example code demonstrating how to use relative layout's layout parameters in a layout XML. To learn more about layout parameters and how they differ from typical view attributes, see the[Layouts guide](https://developer.android.com/guide/topics/ui/declaring-layout.html#attributes).

## Summary

|                                                                                                                                         XML attributes                                                                                                                                         ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|
| [`android:layout_above`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)                    | Positions the bottom edge of this view above the given anchor view ID.                                                               |
| [`android:layout_alignBaseline`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)            | Positions the baseline of this view on the baseline of the given anchor view ID.                                                     |
| [`android:layout_alignBottom`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)              | Makes the bottom edge of this view match the bottom edge of the given anchor view ID.                                                |
| [`android:layout_alignEnd`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)                 | Makes the end edge of this view match the end edge of the given anchor view ID.                                                      |
| [`android:layout_alignLeft`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)                | Makes the left edge of this view match the left edge of the given anchor view ID.                                                    |
| [`android:layout_alignParentBottom`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)        | If true, makes the bottom edge of this view match the bottom edge of the parent.                                                     |
| [`android:layout_alignParentEnd`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)           | If true, makes the end edge of this view match the end edge of the parent.                                                           |
| [`android:layout_alignParentLeft`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)          | If true, makes the left edge of this view match the left edge of the parent.                                                         |
| [`android:layout_alignParentRight`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)         | If true, makes the right edge of this view match the right edge of the parent.                                                       |
| [`android:layout_alignParentStart`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)         | If true, makes the start edge of this view match the start edge of the parent.                                                       |
| [`android:layout_alignParentTop`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)           | If true, makes the top edge of this view match the top edge of the parent.                                                           |
| [`android:layout_alignRight`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)               | Makes the right edge of this view match the right edge of the given anchor view ID.                                                  |
| [`android:layout_alignStart`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)               | Makes the start edge of this view match the start edge of the given anchor view ID.                                                  |
| [`android:layout_alignTop`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)                 | Makes the top edge of this view match the top edge of the given anchor view ID.                                                      |
| [`android:layout_alignWithParentIfMissing`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams) | If set to true, the parent will be used as the anchor when the anchor cannot be be found for layout_toLeftOf, layout_toRightOf, etc. |
| [`android:layout_below`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)                    | Positions the top edge of this view below the given anchor view ID.                                                                  |
| [`android:layout_centerHorizontal`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)         | If true, centers this child horizontally within its parent.                                                                          |
| [`android:layout_centerInParent`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)           | If true, centers this child horizontally and vertically within its parent.                                                           |
| [`android:layout_centerVertical`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)           | If true, centers this child vertically within its parent.                                                                            |
| [`android:layout_toEndOf`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)                  | Positions the start edge of this view to the end of the given anchor view ID.                                                        |
| [`android:layout_toLeftOf`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)                 | Positions the right edge of this view to the left of the given anchor view ID.                                                       |
| [`android:layout_toRightOf`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)                | Positions the left edge of this view to the right of the given anchor view ID.                                                       |
| [`android:layout_toStartOf`](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#attr_LayoutParams)                | Positions the end edge of this view to the start of the given anchor view ID.                                                        |

| Inherited XML attributes ||
|---|---|
| From class[LayoutParams](https://developer.android.com/reference/kotlin/android/view/ViewGroup.LayoutParams.html#) |------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [android:layout_height](https://developer.android.com/reference/kotlin/android/view/ViewGroup.LayoutParams.html#attr_LayoutParams) | Specifies the basic height of the view. This is a required attribute for any view inside of a containing layout manager. Its value may be a dimension (such as "12dip") for a constant height or one of the special constants. May be a dimension value, which is a floating point number appended with a unit such as "`14.5sp`". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). Must be one of the following constant values. |   Constant   |  Value   |                                                                   Description                                                                    | |--------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------| | fill_parent  | ffffffff | The view should be as big as its parent (minus padding). This constant is deprecated starting from API Level 8 and is replaced by`match_parent`. | | match_parent | ffffffff | The view should be as big as its parent (minus padding). Introduced in API Level 8.                                                              | | wrap_content | fffffffe | The view should be only big enough to enclose its content (plus padding).                                                                        | <br /> | | [android:layout_width](https://developer.android.com/reference/kotlin/android/view/ViewGroup.LayoutParams.html#attr_LayoutParams)  | Specifies the basic width of the view. This is a required attribute for any view inside of a containing layout manager. Its value may be a dimension (such as "12dip") for a constant width or one of the special constants. May be a dimension value, which is a floating point number appended with a unit such as "`14.5sp`". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). Must be one of the following constant values. |   Constant   |  Value   |                                                                   Description                                                                    | |--------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------| | fill_parent  | ffffffff | The view should be as big as its parent (minus padding). This constant is deprecated starting from API Level 8 and is replaced by`match_parent`. | | match_parent | ffffffff | The view should be as big as its parent (minus padding). Introduced in API Level 8.                                                              | | wrap_content | fffffffe | The view should be only big enough to enclose its content (plus padding).                                                                        | <br />   | ||
| From class[MarginLayoutParams](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#) |----------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [android:layout_margin](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#attr_MarginLayoutParams)           | Specifies extra space on the left, top, right and bottom sides of this view. If both layout_margin and any of layout_marginLeft, layout_marginRight, layout_marginStart, layout_marginEnd, layout_marginTop, and layout_marginBottom are also specified, the layout_margin value will take precedence over the edge-specific values. This space is outside this view's bounds. Margin values should be positive. May be a dimension value, which is a floating point number appended with a unit such as "`14.5sp`". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). <br />                                                                                                                                                                     | | [android:layout_marginBottom](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#attr_MarginLayoutParams)     | Specifies extra space on the bottom side of this view. This space is outside this view's bounds. Margin values should be positive. May be a dimension value, which is a floating point number appended with a unit such as "`14.5sp`". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                   | | [android:layout_marginEnd](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#attr_MarginLayoutParams)        | Specifies extra space on the end side of this view. This space is outside this view's bounds. Margin values should be positive. May be a dimension value, which is a floating point number appended with a unit such as "`14.5sp`". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                      | | [android:layout_marginHorizontal](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#attr_MarginLayoutParams) | Specifies extra space on the left and right sides of this view. Specifying layout_marginHorizontal is equivalent to specifying layout_marginLeft and layout_marginRight. If both layout_marginHorizontal and either/both of layout_marginLeft and layout_marginRight are also specified, the layout_marginHorizontal value will take precedence over the edge-specific values. Also, layout_margin will always take precedence over any of these values, including layout_marginHorizontal. This space is outside this view's bounds. Margin values should be positive. May be a dimension value, which is a floating point number appended with a unit such as "`14.5sp`". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). <br />              | | [android:layout_marginLeft](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#attr_MarginLayoutParams)       | Specifies extra space on the left side of this view. This space is outside this view's bounds. Margin values should be positive. May be a dimension value, which is a floating point number appended with a unit such as "`14.5sp`". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                     | | [android:layout_marginRight](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#attr_MarginLayoutParams)      | Specifies extra space on the right side of this view. This space is outside this view's bounds. Margin values should be positive. May be a dimension value, which is a floating point number appended with a unit such as "`14.5sp`". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                    | | [android:layout_marginStart](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#attr_MarginLayoutParams)      | Specifies extra space on the start side of this view. This space is outside this view's bounds. Margin values should be positive. May be a dimension value, which is a floating point number appended with a unit such as "`14.5sp`". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                    | | [android:layout_marginTop](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#attr_MarginLayoutParams)        | Specifies extra space on the top side of this view. This space is outside this view's bounds. Margin values should be positive. May be a dimension value, which is a floating point number appended with a unit such as "`14.5sp`". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                      | | [android:layout_marginVertical](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#attr_MarginLayoutParams)   | Specifies extra space on the top and bottom sides of this view. Specifying layout_marginVertical is equivalent to specifying layout_marginTop and layout_marginBottom with that same value. If both layout_marginVertical and either/both of layout_marginTop and layout_marginBottom are also specified, the layout_marginVertical value will take precedence over the edge-specific values. Also, layout_margin will always take precedence over any of these values, including layout_marginVertical. This space is outside this view's bounds. Margin values should be positive. May be a dimension value, which is a floating point number appended with a unit such as "`14.5sp`". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters). <br /> | ||

| Inherited constants ||
|---|---|
| From class[LayoutParams](https://developer.android.com/reference/kotlin/android/view/ViewGroup.LayoutParams.html#) |----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [FILL_PARENT](https://developer.android.com/reference/kotlin/android/view/ViewGroup.LayoutParams.html#FILL_PARENT:kotlin.Int) <br /> Special value for the height or width requested by a View. FILL_PARENT means that the view wants to be as big as its parent, minus the parent's padding, if any. This value is deprecated starting in API Level 8 and replaced by[MATCH_PARENT](https://developer.android.com/reference/kotlin/android/view/ViewGroup.LayoutParams.html#MATCH_PARENT:kotlin.Int). <br /> | | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [MATCH_PARENT](https://developer.android.com/reference/kotlin/android/view/ViewGroup.LayoutParams.html#MATCH_PARENT:kotlin.Int) <br /> 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. Introduced in API Level 8. <br />                                                                                                                                                                    | | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [WRAP_CONTENT](https://developer.android.com/reference/kotlin/android/view/ViewGroup.LayoutParams.html#WRAP_CONTENT:kotlin.Int) <br /> 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. <br />                                                                                                                                                                 | ||

|                                                                                                                                                                                          Public constructors                                                                                                                                                                                          ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [LayoutParams](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#LayoutParams(android.content.Context,%20android.util.AttributeSet))`(`c:` `[Context](https://developer.android.com/reference/kotlin/android/content/Context.html#)!`, `attrs:` `[AttributeSet](https://developer.android.com/reference/kotlin/android/util/AttributeSet.html#)!`)` <br /> |
| [LayoutParams](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#LayoutParams(android.view.ViewGroup.LayoutParams))`(`source:` `[ViewGroup.LayoutParams](https://developer.android.com/reference/kotlin/android/view/ViewGroup.LayoutParams.html#)!`)` <br />                                                                                              |
| [LayoutParams](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#LayoutParams(android.view.ViewGroup.MarginLayoutParams))`(`source:` `[ViewGroup.MarginLayoutParams](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#)!`)` <br />                                                                            |
| [LayoutParams](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#LayoutParams(android.widget.RelativeLayout.LayoutParams))`(`source:` `[RelativeLayout.LayoutParams](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#)!`)` Copy constructor.                                                                     |
| [LayoutParams](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#LayoutParams(kotlin.Int,%20kotlin.Int))`(`w:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `h:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` <br />                                                                    |

|                                                                                                                                                                                                                                                                                Public methods                                                                                                                                                                                                                                                                                 ||
|--------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [addRule](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#addRule(kotlin.Int))`(`verb:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Adds a layout rule to be interpreted by the RelativeLayout.                                                                                                                                                                                                      |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [addRule](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#addRule(kotlin.Int,%20kotlin.Int))`(`verb:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `subject:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Adds a layout rule to be interpreted by the RelativeLayout.                                                                                               |
| open[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!      | [debug](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#debug(kotlin.String))`(`output:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` <br />                                                                                                                                                                                                                                                   |
| open[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)             | [getRule](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#getRule(kotlin.Int))`(`verb:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Returns the layout rule associated with a specific verb.                                                                                                                                                                                                         |
| open[IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)! | [getRules](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#getRules())`()` Retrieves a complete list of all supported rules, where the index is the rule verb, and the element value is the value specified, or "false" if it was never set.                                                                                                                                                                                            |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [removeRule](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#removeRule(kotlin.Int))`(`verb:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Removes a layout rule to be interpreted by the RelativeLayout.                                                                                                                                                                                             |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [resolveLayoutDirection](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#resolveLayoutDirection(kotlin.Int))`(`layoutDirection:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` This will be called by[android.view.View#requestLayout()](https://developer.android.com/reference/kotlin/android/view/View.html#requestLayout())to resolve layout parameters that are relative to the layout direction. |

| Inherited functions ||
|---|---|
| From class[MarginLayoutParams](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#) |------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)         | [getLayoutDirection](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#getLayoutDirection())`()` <br /> Retuns the layout direction. Can be either[View.LAYOUT_DIRECTION_LTR](https://developer.android.com/reference/kotlin/android/view/View.html#LAYOUT_DIRECTION_LTR:kotlin.Int)or[View.LAYOUT_DIRECTION_RTL](https://developer.android.com/reference/kotlin/android/view/View.html#LAYOUT_DIRECTION_RTL:kotlin.Int). <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)         | [getMarginEnd](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#getMarginEnd())`()` <br /> Returns the end margin in pixels. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)         | [getMarginStart](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#getMarginStart())`()` <br /> Returns the start margin in pixels. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [isMarginRelative](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#isMarginRelative())`()` <br /> Check if margins are relative. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [setLayoutDirection](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#setLayoutDirection(kotlin.Int))`(`layoutDirection:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` <br /> Set the layout direction <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [setMarginEnd](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#setMarginEnd(kotlin.Int))`(`end:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` <br /> Sets the relative end margin. Margin values should be positive. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [setMarginStart](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#setMarginStart(kotlin.Int))`(`start:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` <br /> Sets the relative start margin. Margin values should be positive. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [setMargins](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#setMargins(kotlin.Int,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int))`(`left:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `top:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `right:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `bottom:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` <br /> Sets the margins, in pixels. A call to[android.view.View#requestLayout()](https://developer.android.com/reference/kotlin/android/view/View.html#requestLayout())needs to be done so that the new margins are taken into account. Left and right margins may be overridden by[android.view.View#requestLayout()](https://developer.android.com/reference/kotlin/android/view/View.html#requestLayout())depending on layout direction. Margin values should be positive. <br /> | ||
| From class[LayoutParams](https://developer.android.com/reference/kotlin/android/view/ViewGroup.LayoutParams.html#) |------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [setBaseAttributes](https://developer.android.com/reference/kotlin/android/view/ViewGroup.LayoutParams.html#setBaseAttributes(android.content.res.TypedArray,%20kotlin.Int,%20kotlin.Int))`(`a:` `[TypedArray](https://developer.android.com/reference/kotlin/android/content/res/TypedArray.html#)!`, `widthAttr:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `heightAttr:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` <br /> Extracts the layout parameters from the supplied attributes. <br /> | ||

|                                                                                                                                                                 Properties                                                                                                                                                                  ||
|------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [alignWithParent](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#alignWithParent:kotlin.Boolean) When true, uses the parent as the anchor if the anchor doesn't exist or if the anchor's visibility is GONE. |

| Inherited properties ||
|---|---|
| From class[MarginLayoutParams](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#) |----------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [bottomMargin](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#bottomMargin:kotlin.Int) <br /> The bottom margin in pixels of the child. Margin values should be positive. Call[ViewGroup.setLayoutParams(LayoutParams)](https://developer.android.com/reference/kotlin/android/view/View.html#setLayoutParams(android.view.ViewGroup.LayoutParams))after reassigning a new value to this field. <br /> | | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [leftMargin](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#leftMargin:kotlin.Int) <br /> The left margin in pixels of the child. Margin values should be positive. Call[ViewGroup.setLayoutParams(LayoutParams)](https://developer.android.com/reference/kotlin/android/view/View.html#setLayoutParams(android.view.ViewGroup.LayoutParams))after reassigning a new value to this field. <br />       | | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [rightMargin](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#rightMargin:kotlin.Int) <br /> The right margin in pixels of the child. Margin values should be positive. Call[ViewGroup.setLayoutParams(LayoutParams)](https://developer.android.com/reference/kotlin/android/view/View.html#setLayoutParams(android.view.ViewGroup.LayoutParams))after reassigning a new value to this field. <br />    | | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [topMargin](https://developer.android.com/reference/kotlin/android/view/ViewGroup.MarginLayoutParams.html#topMargin:kotlin.Int) <br /> The top margin in pixels of the child. Margin values should be positive. Call[ViewGroup.setLayoutParams(LayoutParams)](https://developer.android.com/reference/kotlin/android/view/View.html#setLayoutParams(android.view.ViewGroup.LayoutParams))after reassigning a new value to this field. <br />          | ||
| From class[LayoutParams](https://developer.android.com/reference/kotlin/android/view/ViewGroup.LayoutParams.html#) |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                                                                                                  | [height](https://developer.android.com/reference/kotlin/android/view/ViewGroup.LayoutParams.html#height:kotlin.Int) <br /> Information about how tall the view wants to be. Can be one of the constants FILL_PARENT (replaced by MATCH_PARENT in API Level 8) or WRAP_CONTENT, or an exact size. <br /> | | [LayoutAnimationController.AnimationParameters](https://developer.android.com/reference/kotlin/android/view/animation/LayoutAnimationController.AnimationParameters.html#)! | [layoutAnimationParameters](https://developer.android.com/reference/kotlin/android/view/ViewGroup.LayoutParams.html#layoutAnimationParameters:android.view.animation.LayoutAnimationController.AnimationParameters) <br /> Used to animate layouts. <br />                                              | | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                                                                                                  | [width](https://developer.android.com/reference/kotlin/android/view/ViewGroup.LayoutParams.html#width:kotlin.Int) <br /> Information about how wide the view wants to be. Can be one of the constants FILL_PARENT (replaced by MATCH_PARENT in API Level 8) or WRAP_CONTENT, or an exact size. <br />   | ||

## XML attributes

### android:layout_above

```
android:layout_above
```
Positions the bottom edge of this view above the given anchor view ID. Accommodates bottom margin of this view and top margin of anchor view.

May be a reference to another resource, in the form "`@[+][`*package* `:]`*type* `/`*name*" or a theme attribute in the form "`?[`*package* `:]`*type* `/`*name*".  

### android:layout_alignBaseline

```
android:layout_alignBaseline
```
Positions the baseline of this view on the baseline of the given anchor view ID.

May be a reference to another resource, in the form "`@[+][`*package* `:]`*type* `/`*name*" or a theme attribute in the form "`?[`*package* `:]`*type* `/`*name*".  

### android:layout_alignBottom

```
android:layout_alignBottom
```
Makes the bottom edge of this view match the bottom edge of the given anchor view ID. Accommodates bottom margin.

May be a reference to another resource, in the form "`@[+][`*package* `:]`*type* `/`*name*" or a theme attribute in the form "`?[`*package* `:]`*type* `/`*name*".  

### android:layout_alignEnd

```
android:layout_alignEnd
```
Makes the end edge of this view match the end edge of the given anchor view ID. Accommodates end margin.

May be a reference to another resource, in the form "`@[+][`*package* `:]`*type* `/`*name*" or a theme attribute in the form "`?[`*package* `:]`*type* `/`*name*".  

### android:layout_alignLeft

```
android:layout_alignLeft
```
Makes the left edge of this view match the left edge of the given anchor view ID. Accommodates left margin.

May be a reference to another resource, in the form "`@[+][`*package* `:]`*type* `/`*name*" or a theme attribute in the form "`?[`*package* `:]`*type* `/`*name*".  

### android:layout_alignParentBottom

```
android:layout_alignParentBottom
```
If true, makes the bottom edge of this view match the bottom edge of the parent. Accommodates bottom margin.

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

### android:layout_alignParentEnd

```
android:layout_alignParentEnd
```
If true, makes the end edge of this view match the end edge of the parent. Accommodates end margin.

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

### android:layout_alignParentLeft

```
android:layout_alignParentLeft
```
If true, makes the left edge of this view match the left edge of the parent. Accommodates left margin.

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

### android:layout_alignParentRight

```
android:layout_alignParentRight
```
If true, makes the right edge of this view match the right edge of the parent. Accommodates right margin.

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

### android:layout_alignParentStart

```
android:layout_alignParentStart
```
If true, makes the start edge of this view match the start edge of the parent. Accommodates start margin.

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

### android:layout_alignParentTop

```
android:layout_alignParentTop
```
If true, makes the top edge of this view match the top edge of the parent. Accommodates top margin.

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

### android:layout_alignRight

```
android:layout_alignRight
```
Makes the right edge of this view match the right edge of the given anchor view ID. Accommodates right margin.

May be a reference to another resource, in the form "`@[+][`*package* `:]`*type* `/`*name*" or a theme attribute in the form "`?[`*package* `:]`*type* `/`*name*".  

### android:layout_alignStart

```
android:layout_alignStart
```
Makes the start edge of this view match the start edge of the given anchor view ID. Accommodates start margin.

May be a reference to another resource, in the form "`@[+][`*package* `:]`*type* `/`*name*" or a theme attribute in the form "`?[`*package* `:]`*type* `/`*name*".  

### android:layout_alignTop

```
android:layout_alignTop
```
Makes the top edge of this view match the top edge of the given anchor view ID. Accommodates top margin.

May be a reference to another resource, in the form "`@[+][`*package* `:]`*type* `/`*name*" or a theme attribute in the form "`?[`*package* `:]`*type* `/`*name*".  

### android:layout_alignWithParentIfMissing

```
android:layout_alignWithParentIfMissing
```
If set to true, the parent will be used as the anchor when the anchor cannot be be found for layout_toLeftOf, layout_toRightOf, etc.

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

### android:layout_below

```
android:layout_below
```
Positions the top edge of this view below the given anchor view ID. Accommodates top margin of this view and bottom margin of anchor view.

May be a reference to another resource, in the form "`@[+][`*package* `:]`*type* `/`*name*" or a theme attribute in the form "`?[`*package* `:]`*type* `/`*name*".  

### android:layout_centerHorizontal

```
android:layout_centerHorizontal
```
If true, centers this child horizontally within its parent.

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

### android:layout_centerInParent

```
android:layout_centerInParent
```
If true, centers this child horizontally and vertically within its parent.

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

### android:layout_centerVertical

```
android:layout_centerVertical
```
If true, centers this child vertically within its parent.

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

### android:layout_toEndOf

```
android:layout_toEndOf
```
Positions the start edge of this view to the end of the given anchor view ID. Accommodates start margin of this view and end margin of anchor view.

May be a reference to another resource, in the form "`@[+][`*package* `:]`*type* `/`*name*" or a theme attribute in the form "`?[`*package* `:]`*type* `/`*name*".  

### android:layout_toLeftOf

```
android:layout_toLeftOf
```
Positions the right edge of this view to the left of the given anchor view ID. Accommodates right margin of this view and left margin of anchor view.

May be a reference to another resource, in the form "`@[+][`*package* `:]`*type* `/`*name*" or a theme attribute in the form "`?[`*package* `:]`*type* `/`*name*".  

### android:layout_toRightOf

```
android:layout_toRightOf
```
Positions the left edge of this view to the right of the given anchor view ID. Accommodates left margin of this view and right margin of anchor view.

May be a reference to another resource, in the form "`@[+][`*package* `:]`*type* `/`*name*" or a theme attribute in the form "`?[`*package* `:]`*type* `/`*name*".  

### android:layout_toStartOf

```
android:layout_toStartOf
```
Positions the end edge of this view to the start of the given anchor view ID. Accommodates end margin of this view and start margin of anchor view.

May be a reference to another resource, in the form "`@[+][`*package* `:]`*type* `/`*name*" or a theme attribute in the form "`?[`*package* `:]`*type* `/`*name*".

## Public constructors

### LayoutParams

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
LayoutParams(
    c: Context!, 
    attrs: AttributeSet!)
```  

### LayoutParams

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
LayoutParams(source: ViewGroup.LayoutParams!)
```  

### LayoutParams

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
LayoutParams(source: ViewGroup.MarginLayoutParams!)
```  

### LayoutParams

Added in[API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
LayoutParams(source: RelativeLayout.LayoutParams!)
```

Copy constructor. Clones the width, height, margin values, and rules of the source.

|                                                                              Parameters                                                                              ||
|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `source` | [RelativeLayout.LayoutParams](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#)!:The layout params to copy from. |

### LayoutParams

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
LayoutParams(
    w: Int, 
    h: Int)
```

## Public methods

### addRule

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun addRule(verb: Int): Unit
```

Adds a layout rule to be interpreted by the RelativeLayout.

This method should only be used for verbs that don't refer to a sibling (ex.[ALIGN_RIGHT](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout#ALIGN_RIGHT:kotlin.Int)) or take a boolean value ([TRUE](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout#TRUE:kotlin.Int)for true or 0 for false). To specify a verb that takes a subject, use[addRule(int,int)](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#addRule(kotlin.Int,%20kotlin.Int)).

If the rule is relative to the layout direction (ex.[ALIGN_PARENT_START](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout#ALIGN_PARENT_START:kotlin.Int)), then the layout direction must be resolved using #resolveLayoutDirection(int) before calling[getRule(int)](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#getRule(kotlin.Int))an absolute rule (ex.[ALIGN_PARENT_LEFT](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout#ALIGN_PARENT_LEFT:kotlin.Int).

|                                                                                                               Parameters                                                                                                                ||
|--------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `verb` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):a layout verb, such as[ALIGN_PARENT_LEFT](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout#ALIGN_PARENT_LEFT:kotlin.Int) |

**See Also**

- [#addRule(int, int)](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#addRule(kotlin.Int,%20kotlin.Int))
- [#removeRule(int)](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#removeRule(kotlin.Int))
- [#getRule(int)](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#getRule(kotlin.Int))  

### addRule

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun addRule(
    verb: Int, 
    subject: Int
): Unit
```

Adds a layout rule to be interpreted by the RelativeLayout.

Use this for verbs that refer to a sibling (ex.[ALIGN_RIGHT](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout#ALIGN_RIGHT:kotlin.Int)) or take a boolean value (ex.[CENTER_IN_PARENT](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout#CENTER_IN_PARENT:kotlin.Int)).

If the rule is relative to the layout direction (ex.[START_OF](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout#START_OF:kotlin.Int)), then the layout direction must be resolved using #resolveLayoutDirection(int) before calling[getRule(int)](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#getRule(kotlin.Int))with an absolute rule (ex.[LEFT_OF](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout#LEFT_OF:kotlin.Int).

|                                                                                                                                            Parameters                                                                                                                                            ||
|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `verb`    | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):a layout verb, such as[ALIGN_RIGHT](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout#ALIGN_RIGHT:kotlin.Int)                                                                   |
| `subject` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the ID of another view to use as an anchor, or a boolean value (represented as[TRUE](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout#TRUE:kotlin.Int)for true or 0 for false) |

**See Also**

- [#addRule(int)](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#addRule(kotlin.Int))
- [#removeRule(int)](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#removeRule(kotlin.Int))
- [#getRule(int)](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#getRule(kotlin.Int))  

### debug

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun debug(output: String!): String!
```  

### getRule

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun getRule(verb: Int): Int
```

Returns the layout rule associated with a specific verb.

|                                                                                                                  Parameters                                                                                                                  ||
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `verb` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):one of the verbs defined by[RelativeLayout](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout), such as ALIGN_WITH_PARENT_LEFT |

|                                                                                                                                                                                             Return                                                                                                                                                                                              ||
|----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | the id of another view to use as an anchor, a boolean value (represented as[RelativeLayout.TRUE](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout#TRUE:kotlin.Int)for true or 0 for false), or -1 for verbs that don't refer to another sibling (for example, ALIGN_WITH_PARENT_BOTTOM) |

**See Also**

- [#addRule(int)](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#addRule(kotlin.Int))
- [#addRule(int, int)](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#addRule(kotlin.Int,%20kotlin.Int))  

### getRules

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun getRules(): IntArray!
```

Retrieves a complete list of all supported rules, where the index is the rule verb, and the element value is the value specified, or "false" if it was never set. There will be no resolution of relative rules done.

|                                                   Return                                                    ||
|----------------------------------------------------------------------------------------|---------------------|
| [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)! | the supported rules |

**See Also**

- [#addRule(int, int)](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#addRule(kotlin.Int,%20kotlin.Int))  

### removeRule

Added in[API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun removeRule(verb: Int): Unit
```

Removes a layout rule to be interpreted by the RelativeLayout.

If the rule is relative to the layout direction (ex.[START_OF](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout#START_OF:kotlin.Int),[ALIGN_PARENT_START](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout#ALIGN_PARENT_START:kotlin.Int), etc.) then the layout direction must be resolved using #resolveLayoutDirection(int) before before calling[getRule(int)](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#getRule(kotlin.Int))with an absolute rule (ex.[LEFT_OF](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout#LEFT_OF:kotlin.Int).

|                                                                                                                  Parameters                                                                                                                   ||
|--------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `verb` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):One of the verbs defined by[RelativeLayout](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout), such as ALIGN_WITH_PARENT_LEFT. |

**See Also**

- [#addRule(int)](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#addRule(kotlin.Int))
- [#addRule(int, int)](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#addRule(kotlin.Int,%20kotlin.Int))
- [#getRule(int)](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#getRule(kotlin.Int))  

### resolveLayoutDirection

Added in[API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun resolveLayoutDirection(layoutDirection: Int): Unit
```

This will be called by[android.view.View#requestLayout()](https://developer.android.com/reference/kotlin/android/view/View.html#requestLayout())to resolve layout parameters that are relative to the layout direction.

After this method is called, any rules using layout-relative verbs (ex.[START_OF](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout#START_OF:kotlin.Int)) previously added via[addRule(int)](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.LayoutParams#addRule(kotlin.Int))may only be accessed via their resolved absolute verbs (ex.[LEFT_OF](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout#LEFT_OF:kotlin.Int)).

|                                                                                                                                                                                          Parameters                                                                                                                                                                                           ||
|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `layoutDirection` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the direction of the layout[View.LAYOUT_DIRECTION_LTR](https://developer.android.com/reference/kotlin/android/view/View.html#LAYOUT_DIRECTION_LTR:kotlin.Int)[View.LAYOUT_DIRECTION_RTL](https://developer.android.com/reference/kotlin/android/view/View.html#LAYOUT_DIRECTION_RTL:kotlin.Int) |

## Properties

### alignWithParent

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var alignWithParent: Boolean
```

When true, uses the parent as the anchor if the anchor doesn't exist or if the anchor's visibility is GONE.