Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [XML Attrs](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#lattrs) \| [Inherited XML Attrs](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#inhattrs) \| [Inherited Constants](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#inhconstants) \| [Fields](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#lfields) \| [Inherited Fields](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#inhfields) \| [Ctors](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#pubctors) \| [Methods](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#inhmethods)

# RelativeLayout.LayoutParams

*** ** * ** ***

` public static class RelativeLayout.LayoutParams `   
` ` ` ` ` extends https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams ` ` `

|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||||
| ↳ | [android.view.ViewGroup.LayoutParams](https://developer.android.com/reference/android/view/ViewGroup.LayoutParams) |||
|   | ↳ | [android.view.ViewGroup.MarginLayoutParams](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams) ||
|   |   | ↳ | android.widget.RelativeLayout.LayoutParams |

<br />

*** ** * ** ***

Specifies how a view is positioned within a `https://developer.android.com/reference/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) 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#attributes).

## Summary

| ### XML attributes ||
|---|---|
| [`android:layout_above`](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#attr_android:layout_above) | Positions the bottom edge of this view above the given anchor view ID. |
| [`android:layout_alignBaseline`](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#attr_android:layout_alignBaseline) | Positions the baseline of this view on the baseline of the given anchor view ID. |
| [`android:layout_alignBottom`](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#attr_android:layout_alignBottom) | 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/android/widget/RelativeLayout.LayoutParams#attr_android:layout_alignEnd) | 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/android/widget/RelativeLayout.LayoutParams#attr_android:layout_alignLeft) | 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/android/widget/RelativeLayout.LayoutParams#attr_android:layout_alignParentBottom) | If true, makes the bottom edge of this view match the bottom edge of the parent. |
| [`android:layout_alignParentEnd`](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#attr_android:layout_alignParentEnd) | If true, makes the end edge of this view match the end edge of the parent. |
| [`android:layout_alignParentLeft`](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#attr_android:layout_alignParentLeft) | If true, makes the left edge of this view match the left edge of the parent. |
| [`android:layout_alignParentRight`](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#attr_android:layout_alignParentRight) | If true, makes the right edge of this view match the right edge of the parent. |
| [`android:layout_alignParentStart`](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#attr_android:layout_alignParentStart) | If true, makes the start edge of this view match the start edge of the parent. |
| [`android:layout_alignParentTop`](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#attr_android:layout_alignParentTop) | If true, makes the top edge of this view match the top edge of the parent. |
| [`android:layout_alignRight`](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#attr_android:layout_alignRight) | 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/android/widget/RelativeLayout.LayoutParams#attr_android:layout_alignStart) | 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/android/widget/RelativeLayout.LayoutParams#attr_android:layout_alignTop) | 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/android/widget/RelativeLayout.LayoutParams#attr_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. |
| [`android:layout_below`](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#attr_android:layout_below) | Positions the top edge of this view below the given anchor view ID. |
| [`android:layout_centerHorizontal`](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#attr_android:layout_centerHorizontal) | If true, centers this child horizontally within its parent. |
| [`android:layout_centerInParent`](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#attr_android:layout_centerInParent) | If true, centers this child horizontally and vertically within its parent. |
| [`android:layout_centerVertical`](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#attr_android:layout_centerVertical) | If true, centers this child vertically within its parent. |
| [`android:layout_toEndOf`](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#attr_android:layout_toEndOf) | Positions the start edge of this view to the end of the given anchor view ID. |
| [`android:layout_toLeftOf`](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#attr_android:layout_toLeftOf) | Positions the right edge of this view to the left of the given anchor view ID. |
| [`android:layout_toRightOf`](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#attr_android:layout_toRightOf) | Positions the left edge of this view to the right of the given anchor view ID. |
| [`android:layout_toStartOf`](https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#attr_android:layout_toStartOf) | Positions the end edge of this view to the start of the given anchor view ID. |

### Inherited XML attributes

From class `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams` [`android:layout_margin`](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#attr_android:layout_margin) Specifies extra space on the left, top, right and bottom sides of this view. [`android:layout_marginBottom`](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#attr_android:layout_marginBottom) Specifies extra space on the bottom side of this view. [`android:layout_marginEnd`](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#attr_android:layout_marginEnd) Specifies extra space on the end side of this view. [`android:layout_marginHorizontal`](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#attr_android:layout_marginHorizontal) Specifies extra space on the left and right sides of this view. [`android:layout_marginLeft`](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#attr_android:layout_marginLeft) Specifies extra space on the left side of this view. [`android:layout_marginRight`](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#attr_android:layout_marginRight) Specifies extra space on the right side of this view. [`android:layout_marginStart`](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#attr_android:layout_marginStart) Specifies extra space on the start side of this view. [`android:layout_marginTop`](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#attr_android:layout_marginTop) Specifies extra space on the top side of this view. [`android:layout_marginVertical`](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#attr_android:layout_marginVertical) Specifies extra space on the top and bottom sides of this view. From class `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams` [`android:layout_height`](https://developer.android.com/reference/android/view/ViewGroup.LayoutParams#attr_android:layout_height) Specifies the basic height of the view. [`android:layout_width`](https://developer.android.com/reference/android/view/ViewGroup.LayoutParams#attr_android:layout_width) Specifies the basic width of the view.

### Inherited constants

From class `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams` `int` `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams#FILL_PARENT`

Special value for the height or width requested by a View.
`int` `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams#MATCH_PARENT`

Special value for the height or width requested by a View.
`int` `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams#WRAP_CONTENT`

Special value for the height or width requested by a View.

| ### Fields ||
|---|---|
| ` public boolean` | `https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#alignWithParent` When true, uses the parent as the anchor if the anchor doesn't exist or if the anchor's visibility is GONE. |

### Inherited fields

From class `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams` ` public int` `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#bottomMargin`

The bottom margin in pixels of the child.
` public int` `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#leftMargin`

The left margin in pixels of the child.
` public int` `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#rightMargin`

The right margin in pixels of the child.
` public int` `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#topMargin`

The top margin in pixels of the child.
From class `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams` ` public int` `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams#height`

Information about how tall the view wants to be.
` public https://developer.android.com/reference/android/view/animation/LayoutAnimationController.AnimationParameters` `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams#layoutAnimationParameters`

Used to animate layouts.
` public int` `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams#width`

Information about how wide the view wants to be.

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#LayoutParams(android.content.Context,%20android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context c, https://developer.android.com/reference/android/util/AttributeSet attrs) ` |
| ` https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#LayoutParams(android.view.ViewGroup.LayoutParams)(https://developer.android.com/reference/android/view/ViewGroup.LayoutParams source) ` <br /> |
| ` https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#LayoutParams(android.view.ViewGroup.MarginLayoutParams)(https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams source) ` <br /> |
| ` https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#LayoutParams(android.widget.RelativeLayout.LayoutParams)(https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams source) ` Copy constructor. |
| ` https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#LayoutParams(int,%20int)(int w, int h) ` |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#addRule(int,%20int)(int verb, int subject) ` Adds a layout rule to be interpreted by the RelativeLayout. |
| ` void` | ` https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#addRule(int)(int verb) ` Adds a layout rule to be interpreted by the RelativeLayout. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#debug(java.lang.String)(https://developer.android.com/reference/java/lang/String output) ` <br /> |
| ` int` | ` https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#getRule(int)(int verb) ` Returns the layout rule associated with a specific verb. |
| ` int[]` | ` https://developer.android.com/reference/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. |
| ` void` | ` https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#removeRule(int)(int verb) ` Removes a layout rule to be interpreted by the RelativeLayout. |
| ` void` | ` https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#resolveLayoutDirection(int)(int layoutDirection) ` This will be called by `https://developer.android.com/reference/android/view/View#requestLayout()` to resolve layout parameters that are relative to the layout direction. |

### Inherited methods

From class ` https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams ` ` int` ` https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#getLayoutDirection()() `

Retuns the layout direction.
` int` ` https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#getMarginEnd()() `

Returns the end margin in pixels.
` int` ` https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#getMarginStart()() `

Returns the start margin in pixels.
` boolean` ` https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#isMarginRelative()() `

Check if margins are relative.
` void` ` https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#resolveLayoutDirection(int)(int layoutDirection) `

This will be called by `https://developer.android.com/reference/android/view/View#requestLayout()`.
` void` ` https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#setLayoutDirection(int)(int layoutDirection) `

Set the layout direction
` void` ` https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#setMarginEnd(int)(int end) `

Sets the relative end margin.
` void` ` https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#setMarginStart(int)(int start) `

Sets the relative start margin.
` void` ` https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams#setMargins(int,%20int,%20int,%20int)(int left, int top, int right, int bottom) `

Sets the margins, in pixels.
From class ` https://developer.android.com/reference/android/view/ViewGroup.LayoutParams ` ` void` ` https://developer.android.com/reference/android/view/ViewGroup.LayoutParams#resolveLayoutDirection(int)(int layoutDirection) `

Resolve layout parameters depending on the layout direction.
` void` ` https://developer.android.com/reference/android/view/ViewGroup.LayoutParams#setBaseAttributes(android.content.res.TypedArray,%20int,%20int)(https://developer.android.com/reference/android/content/res/TypedArray a, int widthAttr, int heightAttr) `

Extracts the layout parameters from the supplied attributes.
From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## XML attributes

### 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*`".

<br />

### 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*`".

<br />

### 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*`".

<br />

### 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*`".

<br />

### 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*`".

<br />

### 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`".

<br />

### 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`".

<br />

### 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`".

<br />

### 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`".

<br />

### 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`".

<br />

### 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`".

<br />

### 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*`".

<br />

### 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*`".

<br />

### 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*`".

<br />

### 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`".

<br />

### 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*`".

<br />

### android:layout_centerHorizontal

If true, centers this child horizontally within its parent.

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

<br />

### android:layout_centerInParent

If true, centers this child horizontally and vertically within its parent.

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

<br />

### android:layout_centerVertical

If true, centers this child vertically within its parent.

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

<br />

### 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*`".

<br />

### 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*`".

<br />

### 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*`".

<br />

### 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*`".

<br />

## Fields

### alignWithParent

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

```
public boolean alignWithParent
```

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

<br />

## Public constructors

### LayoutParams

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

```
public LayoutParams (Context c, 
                AttributeSet attrs)
```

<br />

<br />

| Parameters ||
|---|---|
| `c` | `Context` <br /> |
| `attrs` | `AttributeSet` <br /> |

### LayoutParams

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

```
public LayoutParams (ViewGroup.LayoutParams source)
```

<br />

<br />

| Parameters ||
|---|---|
| `source` | `ViewGroup.LayoutParams` <br /> |

### LayoutParams

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

```
public LayoutParams (ViewGroup.MarginLayoutParams source)
```

<br />

<br />

| Parameters ||
|---|---|
| `source` | `ViewGroup.MarginLayoutParams` <br /> |

### LayoutParams

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

```
public LayoutParams (RelativeLayout.LayoutParams source)
```

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

<br />

| Parameters ||
|---|---|
| `source` | `RelativeLayout.LayoutParams`: The layout params to copy from. <br /> |

### LayoutParams

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

```
public LayoutParams (int w, 
                int h)
```

<br />

<br />

| Parameters ||
|---|---|
| `w` | `int` <br /> |
| `h` | `int` <br /> |

## Public methods

### addRule

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

```
public void addRule (int verb, 
                int subject)
```

Adds a layout rule to be interpreted by the RelativeLayout.

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

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

<br />

| Parameters ||
|---|---|
| `verb` | `int`: a layout verb, such as `https://developer.android.com/reference/android/widget/RelativeLayout#ALIGN_RIGHT` <br /> |
| `subject` | `int`: the ID of another view to use as an anchor, or a boolean value (represented as `https://developer.android.com/reference/android/widget/RelativeLayout#TRUE` for true or 0 for false) <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#addRule(int)`
- `https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#removeRule(int)`
- `https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#getRule(int)`

### addRule

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

```
public void addRule (int verb)
```

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. `https://developer.android.com/reference/android/widget/RelativeLayout#ALIGN_RIGHT`) or take a boolean value (`https://developer.android.com/reference/android/widget/RelativeLayout#TRUE` for true or 0 for false). To specify a verb that takes a subject, use `https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams#addRule(int,%20int)`.

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

<br />

| Parameters ||
|---|---|
| `verb` | `int`: a layout verb, such as `https://developer.android.com/reference/android/widget/RelativeLayout#ALIGN_PARENT_LEFT` <br /> |

**See also:**

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

### debug

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

```
public String debug (String output)
```

<br />

<br />

| Parameters ||
|---|---|
| `output` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### getRule

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

```
public int getRule (int verb)
```

Returns the layout rule associated with a specific verb.

<br />

| Parameters ||
|---|---|
| `verb` | `int`: one of the verbs defined by `https://developer.android.com/reference/android/widget/RelativeLayout`, such as ALIGN_WITH_PARENT_LEFT <br /> |

| Returns ||
|---|---|
| `int` | the id of another view to use as an anchor, a boolean value (represented as `https://developer.android.com/reference/android/widget/RelativeLayout#TRUE` for true or 0 for false), or -1 for verbs that don't refer to another sibling (for example, ALIGN_WITH_PARENT_BOTTOM) <br /> |

**See also:**

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

### getRules

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

```
public int[] 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. There will be no resolution of relative rules done.

<br />

| Returns ||
|---|---|
| `int[]` | the supported rules <br /> |

**See also:**

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

### removeRule

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

```
public void removeRule (int verb)
```

Removes a layout rule to be interpreted by the RelativeLayout.

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

<br />

| Parameters ||
|---|---|
| `verb` | `int`: One of the verbs defined by `https://developer.android.com/reference/android/widget/RelativeLayout`, such as ALIGN_WITH_PARENT_LEFT. <br /> |

**See also:**

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

### resolveLayoutDirection

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

```
public void resolveLayoutDirection (int layoutDirection)
```

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

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

<br />

| Parameters ||
|---|---|
| `layoutDirection` | `int`: the direction of the layout `https://developer.android.com/reference/android/view/View#LAYOUT_DIRECTION_LTR` `https://developer.android.com/reference/android/view/View#LAYOUT_DIRECTION_RTL` <br /> |