added in version 22.1.0
belongs to Maven artifact


public final class MarginLayoutParamsCompat
extends Object


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


Public methods

static int getLayoutDirection(ViewGroup.MarginLayoutParams lp)

Returns the layout direction.

static int getMarginEnd(ViewGroup.MarginLayoutParams lp)

Get the relative ending margin that was set.

static int getMarginStart(ViewGroup.MarginLayoutParams lp)

Get the relative starting margin that was set.

static boolean isMarginRelative(ViewGroup.MarginLayoutParams lp)

Check if margins are relative.

static void resolveLayoutDirection(ViewGroup.MarginLayoutParams lp, int layoutDirection)

This will be called by requestLayout().

static void setLayoutDirection(ViewGroup.MarginLayoutParams lp, int layoutDirection)

Set the layout direction.

static void setMarginEnd(ViewGroup.MarginLayoutParams lp, int marginEnd)

Set the relative end margin.

static void setMarginStart(ViewGroup.MarginLayoutParams lp, int marginStart)

Set the relative start margin.

Inherited methods

From class java.lang.Object

Public methods


added in version 22.1.0
int getLayoutDirection (ViewGroup.MarginLayoutParams lp)

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

lp ViewGroup.MarginLayoutParams

int the layout direction.


added in version 22.1.0
int getMarginEnd (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.

lp ViewGroup.MarginLayoutParams: LayoutParams to query

int the margin along the ending edge in pixels


added in version 22.1.0