MarginLayoutParamsCompat

Added in 1.1.0
Deprecated in 1.13.0

class MarginLayoutParamsCompat


Helper for accessing API features in MarginLayoutParams in a backwards compatible way.

Summary

Public functions

java-static Int

This function is deprecated.

Use getLayoutDirection directly.

java-static Int
@ReplaceWith(expression = "lp.getMarginEnd()")
getMarginEnd(lp: ViewGroup.MarginLayoutParams)

This function is deprecated.

Use getMarginStart directly.

java-static Int
@ReplaceWith(expression = "lp.getMarginStart()")
getMarginStart(lp: ViewGroup.MarginLayoutParams)

This function is deprecated.

Use getMarginStart directly.

java-static Boolean
@ReplaceWith(expression = "lp.isMarginRelative()")
isMarginRelative(lp: ViewGroup.MarginLayoutParams)

This function is deprecated.

Use isMarginRelative directly.

java-static Unit
@ReplaceWith(expression = "lp.resolveLayoutDirection(layoutDirection)")
resolveLayoutDirection(
    lp: ViewGroup.MarginLayoutParams,
    layoutDirection: Int
)

This function is deprecated.

Use resolveLayoutDirection directly.

java-static Unit
@ReplaceWith(expression = "lp.setLayoutDirection(layoutDirection)")
setLayoutDirection(
    lp: ViewGroup.MarginLayoutParams,
    layoutDirection: Int
)

This function is deprecated.

Use setLayoutDirection directly.

java-static Unit
@ReplaceWith(expression = "lp.setMarginEnd(marginEnd)")
setMarginEnd(lp: ViewGroup.MarginLayoutParams, marginEnd: Int)

This function is deprecated.

Use setMarginEnd directly.

java-static Unit
@ReplaceWith(expression = "lp.setMarginStart(marginStart)")
setMarginStart(lp: ViewGroup.MarginLayoutParams, marginStart: Int)

This function is deprecated.

Use setMarginStart directly.

Public functions

getLayoutDirection

Added in 1.1.0
Deprecated in 1.13.0
java-static fun getLayoutDirection(lp: ViewGroup.MarginLayoutParams): Int

Returns the layout direction. Can be either LAYOUT_DIRECTION_LTR or LAYOUT_DIRECTION_RTL.

Returns
Int

the layout direction.

getMarginEnd

Added in 1.1.0
Deprecated in 1.13.0
@ReplaceWith(expression = "lp.getMarginEnd()")
java-static fun getMarginEnd(lp: ViewGroup.MarginLayoutParams): Int

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

LayoutParams to query

Returns
Int

the margin along the ending edge in pixels

getMarginStart

Added in 1.1.0
Deprecated in 1.13.0
@ReplaceWith(expression = "lp.getMarginStart()")
java-static fun getMarginStart(lp: ViewGroup.MarginLayoutParams): Int

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

LayoutParams to query

Returns
Int

the margin along the starting edge in pixels

isMarginRelative

Added in 1.1.0
Deprecated in 1.13.0
@ReplaceWith(expression = "lp.isMarginRelative()")
java-static fun isMarginRelative(lp: ViewGroup.MarginLayoutParams): Boolean

Check if margins are relative.

Returns
Boolean

true if either marginStart or marginEnd has been set.

resolveLayoutDirection

Added in 1.1.0
Deprecated in 1.13.0
@ReplaceWith(expression = "lp.resolveLayoutDirection(layoutDirection)")
java-static fun resolveLayoutDirection(
    lp: ViewGroup.MarginLayoutParams,
    layoutDirection: Int
): Unit

This will be called by requestLayout. Left and Right margins may be overridden depending on layout direction.

setLayoutDirection

Added in 1.1.0
Deprecated in 1.13.0
@ReplaceWith(expression = "lp.setLayoutDirection(layoutDirection)")
java-static fun setLayoutDirection(
    lp: ViewGroup.MarginLayoutParams,
    layoutDirection: Int
): Unit

Set the layout direction.

Parameters
lp: ViewGroup.MarginLayoutParams

LayoutParameters for which to set the layout direction.

layoutDirection: Int

the layout direction. Should be either LAYOUT_DIRECTION_LTR or LAYOUT_DIRECTION_RTL.

setMarginEnd

Added in 1.1.0
Deprecated in 1.13.0
@ReplaceWith(expression = "lp.setMarginEnd(marginEnd)")
java-static fun setMarginEnd(lp: ViewGroup.MarginLayoutParams, marginEnd: Int): Unit

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

LayoutParams to query

marginEnd: Int

the desired end margin in pixels

setMarginStart

Added in 1.1.0
Deprecated in 1.13.0
@ReplaceWith(expression = "lp.setMarginStart(marginStart)")
java-static fun setMarginStart(lp: ViewGroup.MarginLayoutParams, marginStart: Int): Unit

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

LayoutParams to query

marginStart: Int

the desired start margin in pixels