# MarginLayoutParamsCompat

# MarginLayoutParamsCompat

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/view/MarginLayoutParamsCompat.java+class:androidx.core.view.MarginLayoutParamsCompat)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  
Deprecated in[1.13.0](https://developer.android.com/jetpack/androidx/releases/core#1.13.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/view/MarginLayoutParamsCompat "View this page in Java")

<br />

```
class MarginLayoutParamsCompat
```

<br />

*** ** * ** ***

| **This class is deprecated.**   
|
| Use[ViewGroup.MarginLayoutParams](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html)directly.

Helper for accessing API features in[MarginLayoutParams](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html)in a backwards compatible way.

## Summary

|                                       ### Public functions                                        |
|---------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)         | ~~[getLayoutDirection](https://developer.android.com/reference/kotlin/androidx/core/view/MarginLayoutParamsCompat#getLayoutDirection(android.view.ViewGroup.MarginLayoutParams))~~`(lp: `[ViewGroup.MarginLayoutParams](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html)`)` **This function is deprecated.** Use[getLayoutDirection](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html#getLayoutDirection())directly. <br />                                                                                                                                                                                                                                                                                              |
| `java-static `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)         | `@`[ReplaceWith](https://developer.android.com/reference/kotlin/androidx/annotation/ReplaceWith)`(expression = "lp.getMarginEnd()")` ~~[getMarginEnd](https://developer.android.com/reference/kotlin/androidx/core/view/MarginLayoutParamsCompat#getMarginEnd(android.view.ViewGroup.MarginLayoutParams))~~`(lp: `[ViewGroup.MarginLayoutParams](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html)`)` **This function is deprecated.** Use[getMarginStart](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html#getMarginStart())directly. <br />                                                                                                                                                                             |
| `java-static `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)         | `@`[ReplaceWith](https://developer.android.com/reference/kotlin/androidx/annotation/ReplaceWith)`(expression = "lp.getMarginStart()")` ~~[getMarginStart](https://developer.android.com/reference/kotlin/androidx/core/view/MarginLayoutParamsCompat#getMarginStart(android.view.ViewGroup.MarginLayoutParams))~~`(lp: `[ViewGroup.MarginLayoutParams](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html)`)` **This function is deprecated.** Use[getMarginStart](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html#getMarginStart())directly. <br />                                                                                                                                                                       |
| `java-static `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `@`[ReplaceWith](https://developer.android.com/reference/kotlin/androidx/annotation/ReplaceWith)`(expression = "lp.isMarginRelative()")` ~~[isMarginRelative](https://developer.android.com/reference/kotlin/androidx/core/view/MarginLayoutParamsCompat#isMarginRelative(android.view.ViewGroup.MarginLayoutParams))~~`(lp: `[ViewGroup.MarginLayoutParams](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html)`)` **This function is deprecated.** Use[isMarginRelative](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html#isMarginRelative())directly. <br />                                                                                                                                                             |
| `java-static `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | `@`[ReplaceWith](https://developer.android.com/reference/kotlin/androidx/annotation/ReplaceWith)`(expression = "lp.resolveLayoutDirection(layoutDirection)")` ~~[resolveLayoutDirection](https://developer.android.com/reference/kotlin/androidx/core/view/MarginLayoutParamsCompat#resolveLayoutDirection(android.view.ViewGroup.MarginLayoutParams,int))~~`(` ` lp: `[ViewGroup.MarginLayoutParams](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html)`,` ` layoutDirection: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) `)` **This function is deprecated.** Use[resolveLayoutDirection](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html#resolveLayoutDirection(int))directly. <br /> |
| `java-static `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | `@`[ReplaceWith](https://developer.android.com/reference/kotlin/androidx/annotation/ReplaceWith)`(expression = "lp.setLayoutDirection(layoutDirection)")` ~~[setLayoutDirection](https://developer.android.com/reference/kotlin/androidx/core/view/MarginLayoutParamsCompat#setLayoutDirection(android.view.ViewGroup.MarginLayoutParams,int))~~`(` ` lp: `[ViewGroup.MarginLayoutParams](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html)`,` ` layoutDirection: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) `)` **This function is deprecated.** Use[setLayoutDirection](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html#setLayoutDirection(int))directly. <br />                     |
| `java-static `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | `@`[ReplaceWith](https://developer.android.com/reference/kotlin/androidx/annotation/ReplaceWith)`(expression = "lp.setMarginEnd(marginEnd)")` ~~[setMarginEnd](https://developer.android.com/reference/kotlin/androidx/core/view/MarginLayoutParamsCompat#setMarginEnd(android.view.ViewGroup.MarginLayoutParams,int))~~`(lp: `[ViewGroup.MarginLayoutParams](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html)`, marginEnd: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` **This function is deprecated.** Use[setMarginEnd](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html#setMarginEnd(int))directly. <br />                                                                       |
| `java-static `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | `@`[ReplaceWith](https://developer.android.com/reference/kotlin/androidx/annotation/ReplaceWith)`(expression = "lp.setMarginStart(marginStart)")` ~~[setMarginStart](https://developer.android.com/reference/kotlin/androidx/core/view/MarginLayoutParamsCompat#setMarginStart(android.view.ViewGroup.MarginLayoutParams,int))~~`(lp: `[ViewGroup.MarginLayoutParams](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html)`, marginStart: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` **This function is deprecated.** Use[setMarginStart](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html#setMarginStart(int))directly. <br />                                                         |

## Public functions

### getLayoutDirection

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  
Deprecated in[1.13.0](https://developer.android.com/jetpack/androidx/releases/core#1.13.0)  

```
java-static fun [getLayoutDirection](https://developer.android.com/reference/kotlin/androidx/core/view/MarginLayoutParamsCompat#getLayoutDirection(android.view.ViewGroup.MarginLayoutParams))(lp: ViewGroup.MarginLayoutParams): Int
```
| **This function is deprecated.**   
|
| Use[getLayoutDirection](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html#getLayoutDirection())directly.

Returns the layout direction. Can be either[LAYOUT_DIRECTION_LTR](https://developer.android.com/reference/kotlin/androidx/core/view/ViewCompat#LAYOUT_DIRECTION_LTR())or[LAYOUT_DIRECTION_RTL](https://developer.android.com/reference/kotlin/androidx/core/view/ViewCompat#LAYOUT_DIRECTION_RTL()).  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|-----------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the layout direction. |

### getMarginEnd

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  
Deprecated in[1.13.0](https://developer.android.com/jetpack/androidx/releases/core#1.13.0)  

```
@ReplaceWith(expression = "lp.getMarginEnd()")
java-static fun [getMarginEnd](https://developer.android.com/reference/kotlin/androidx/core/view/MarginLayoutParamsCompat#getMarginEnd(android.view.ViewGroup.MarginLayoutParams))(lp: ViewGroup.MarginLayoutParams): Int
```
| **This function is deprecated.**   
|
| Use[getMarginStart](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html#getMarginStart())directly.

Get the relative ending margin that was set.

On platform versions supporting bidirectional text and layouts this value will be resolved into the LayoutParams object's left or right margin as appropriate when the associated View is attached to a window or when the layout direction of that view changes.  

|                                                          Parameters                                                          |
|------------------------------------------------------------------------------------------------------------------------------|-----------------------|
| `lp: `[ViewGroup.MarginLayoutParams](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html) | LayoutParams to query |

|                                   Returns                                   |
|-----------------------------------------------------------------------------|--------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the margin along the ending edge in pixels |

### getMarginStart

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  
Deprecated in[1.13.0](https://developer.android.com/jetpack/androidx/releases/core#1.13.0)  

```
@ReplaceWith(expression = "lp.getMarginStart()")
java-static fun [getMarginStart](https://developer.android.com/reference/kotlin/androidx/core/view/MarginLayoutParamsCompat#getMarginStart(android.view.ViewGroup.MarginLayoutParams))(lp: ViewGroup.MarginLayoutParams): Int
```
| **This function is deprecated.**   
|
| Use[getMarginStart](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html#getMarginStart())directly.

Get the relative starting margin that was set.

On platform versions supporting bidirectional text and layouts this value will be resolved into the LayoutParams object's left or right margin as appropriate when the associated View is attached to a window or when the layout direction of that view changes.  

|                                                          Parameters                                                          |
|------------------------------------------------------------------------------------------------------------------------------|-----------------------|
| `lp: `[ViewGroup.MarginLayoutParams](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html) | LayoutParams to query |

|                                   Returns                                   |
|-----------------------------------------------------------------------------|----------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the margin along the starting edge in pixels |

### isMarginRelative

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  
Deprecated in[1.13.0](https://developer.android.com/jetpack/androidx/releases/core#1.13.0)  

```
@ReplaceWith(expression = "lp.isMarginRelative()")
java-static fun [isMarginRelative](https://developer.android.com/reference/kotlin/androidx/core/view/MarginLayoutParamsCompat#isMarginRelative(android.view.ViewGroup.MarginLayoutParams))(lp: ViewGroup.MarginLayoutParams): Boolean
```
| **This function is deprecated.**   
|
| Use[isMarginRelative](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html#isMarginRelative())directly.

Check if margins are relative.  

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|-------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | true if either marginStart or marginEnd has been set. |

### resolveLayoutDirection

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  
Deprecated in[1.13.0](https://developer.android.com/jetpack/androidx/releases/core#1.13.0)  

```
@ReplaceWith(expression = "lp.resolveLayoutDirection(layoutDirection)")
java-static fun [resolveLayoutDirection](https://developer.android.com/reference/kotlin/androidx/core/view/MarginLayoutParamsCompat#resolveLayoutDirection(android.view.ViewGroup.MarginLayoutParams,int))(
    lp: ViewGroup.MarginLayoutParams,
    layoutDirection: Int
): Unit
```
| **This function is deprecated.**   
|
| Use[resolveLayoutDirection](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html#resolveLayoutDirection(int))directly.

This will be called by[requestLayout](https://developer.android.com/reference/android/view/View.html#requestLayout()). Left and Right margins may be overridden depending on layout direction.  

### setLayoutDirection

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  
Deprecated in[1.13.0](https://developer.android.com/jetpack/androidx/releases/core#1.13.0)  

```
@ReplaceWith(expression = "lp.setLayoutDirection(layoutDirection)")
java-static fun [setLayoutDirection](https://developer.android.com/reference/kotlin/androidx/core/view/MarginLayoutParamsCompat#setLayoutDirection(android.view.ViewGroup.MarginLayoutParams,int))(
    lp: ViewGroup.MarginLayoutParams,
    layoutDirection: Int
): Unit
```
| **This function is deprecated.**   
|
| Use[setLayoutDirection](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html#setLayoutDirection(int))directly.

Set the layout direction.  

|                                                          Parameters                                                          |
|------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `lp: `[ViewGroup.MarginLayoutParams](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html) | LayoutParameters for which to set the layout direction.                                                                                                                                                                                                                                         |
| `layoutDirection: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                               | the layout direction. Should be either[LAYOUT_DIRECTION_LTR](https://developer.android.com/reference/kotlin/androidx/core/view/ViewCompat#LAYOUT_DIRECTION_LTR())or[LAYOUT_DIRECTION_RTL](https://developer.android.com/reference/kotlin/androidx/core/view/ViewCompat#LAYOUT_DIRECTION_RTL()). |

### setMarginEnd

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  
Deprecated in[1.13.0](https://developer.android.com/jetpack/androidx/releases/core#1.13.0)  

```
@ReplaceWith(expression = "lp.setMarginEnd(marginEnd)")
java-static fun [setMarginEnd](https://developer.android.com/reference/kotlin/androidx/core/view/MarginLayoutParamsCompat#setMarginEnd(android.view.ViewGroup.MarginLayoutParams,int))(lp: ViewGroup.MarginLayoutParams, marginEnd: Int): Unit
```
| **This function is deprecated.**   
|
| Use[setMarginEnd](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html#setMarginEnd(int))directly.

Set the relative end margin.

On platform versions supporting bidirectional text and layouts this value will be resolved into the LayoutParams object's left or right margin as appropriate when the associated View is attached to a window or when the layout direction of that view changes.  

|                                                          Parameters                                                          |
|------------------------------------------------------------------------------------------------------------------------------|----------------------------------|
| `lp: `[ViewGroup.MarginLayoutParams](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html) | LayoutParams to query            |
| `marginEnd: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                     | the desired end margin in pixels |

### setMarginStart

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  
Deprecated in[1.13.0](https://developer.android.com/jetpack/androidx/releases/core#1.13.0)  

```
@ReplaceWith(expression = "lp.setMarginStart(marginStart)")
java-static fun [setMarginStart](https://developer.android.com/reference/kotlin/androidx/core/view/MarginLayoutParamsCompat#setMarginStart(android.view.ViewGroup.MarginLayoutParams,int))(lp: ViewGroup.MarginLayoutParams, marginStart: Int): Unit
```
| **This function is deprecated.**   
|
| Use[setMarginStart](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html#setMarginStart(int))directly.

Set the relative start margin.

On platform versions supporting bidirectional text and layouts this value will be resolved into the LayoutParams object's left or right margin as appropriate when the associated View is attached to a window or when the layout direction of that view changes.  

|                                                          Parameters                                                          |
|------------------------------------------------------------------------------------------------------------------------------|------------------------------------|
| `lp: `[ViewGroup.MarginLayoutParams](https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html) | LayoutParams to query              |
| `marginStart: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                   | the desired start margin in pixels |