MarginLayoutParamsCompat

Added in 1.1.0
Deprecated in 1.13.0

public final class MarginLayoutParamsCompat


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

Summary

Public methods

static int

This method is deprecated.

Use getLayoutDirection directly.

static int
@ReplaceWith(expression = "lp.getMarginEnd()")
getMarginEnd(@NonNull ViewGroup.MarginLayoutParams lp)

This method is deprecated.

Use getMarginStart directly.

static int
@ReplaceWith(expression = "lp.getMarginStart()")
getMarginStart(@NonNull ViewGroup.MarginLayoutParams lp)

This method is deprecated.

Use getMarginStart directly.

static boolean
@ReplaceWith(expression = "lp.isMarginRelative()")
isMarginRelative(@NonNull ViewGroup.MarginLayoutParams lp)

This method is deprecated.

Use isMarginRelative directly.

static void
@ReplaceWith(expression = "lp.resolveLayoutDirection(layoutDirection)")
resolveLayoutDirection(
    @NonNull ViewGroup.MarginLayoutParams lp,
    int layoutDirection
)

This method is deprecated.

Use resolveLayoutDirection directly.

static void
@ReplaceWith(expression = "lp.setLayoutDirection(layoutDirection)")
setLayoutDirection(
    @NonNull ViewGroup.MarginLayoutParams lp,
    int layoutDirection
)

This method is deprecated.

Use setLayoutDirection directly.

static void
@ReplaceWith(expression = "lp.setMarginEnd(marginEnd)")
setMarginEnd(@NonNull ViewGroup.MarginLayoutParams lp, int marginEnd)

This method is deprecated.

Use setMarginEnd directly.

static void
@ReplaceWith(expression = "lp.setMarginStart(marginStart)")
setMarginStart(@NonNull ViewGroup.MarginLayoutParams lp, int marginStart)

This method is deprecated.

Use setMarginStart directly.

Public methods

getLayoutDirection

Added in 1.1.0
Deprecated in 1.13.0
public static int getLayoutDirection(@NonNull ViewGroup.MarginLayoutParams lp)

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()")
public static int getMarginEnd(@NonNull ViewGroup.MarginLayoutParams lp)

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
@NonNull ViewGroup.MarginLayoutParams lp

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()")
public static int getMarginStart(@NonNull ViewGroup.MarginLayoutParams lp)

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
@NonNull ViewGroup.MarginLayoutParams lp

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()")
public static boolean isMarginRelative(@NonNull ViewGroup.MarginLayoutParams lp)

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)")
public static void resolveLayoutDirection(
    @NonNull ViewGroup.MarginLayoutParams lp,
    int layoutDirection
)

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)")
public static void setLayoutDirection(
    @NonNull ViewGroup.MarginLayoutParams lp,
    int layoutDirection
)

Set the layout direction.

Parameters
@NonNull ViewGroup.MarginLayoutParams lp

LayoutParameters for which to set the layout direction.

int layoutDirection

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)")
public static void setMarginEnd(@NonNull ViewGroup.MarginLayoutParams lp, int marginEnd)

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
@NonNull ViewGroup.MarginLayoutParams lp

LayoutParams to query

int marginEnd

the desired end margin in pixels

setMarginStart

Added in 1.1.0
Deprecated in 1.13.0
@ReplaceWith(expression = "lp.setMarginStart(marginStart)")
public static void setMarginStart(@NonNull ViewGroup.MarginLayoutParams lp, int marginStart)

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
@NonNull ViewGroup.MarginLayoutParams lp

LayoutParams to query

int marginStart

the desired start margin in pixels