MarginLayoutParamsCompat

Added in 1.1.0

class MarginLayoutParamsCompat


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

Summary

Public functions

java-static Int

Returns the layout direction.

java-static Int

Get the relative ending margin that was set.

java-static Int

Get the relative starting margin that was set.

java-static Boolean

Check if margins are relative.

java-static Unit
resolveLayoutDirection(
    lp: ViewGroup.MarginLayoutParams,
    layoutDirection: Int
)

This will be called by requestLayout.

java-static Unit
setLayoutDirection(
    lp: ViewGroup.MarginLayoutParams,
    layoutDirection: Int
)

Set the layout direction.

java-static Unit

Set the relative end margin.

java-static Unit

Set the relative start margin.

Public functions

getLayoutDirection

Added in 1.1.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
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
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
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
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
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
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
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