Skip to content

Most visited

Recently visited

navigation

MarginLayoutParamsCompat

public final class MarginLayoutParamsCompat
extends Object

java.lang.Object
   ↳ android.support.v4.view.MarginLayoutParamsCompat


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

Summary

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

getLayoutDirection

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

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

Parameters
lp ViewGroup.MarginLayoutParams

Returns
int the layout direction.

getMarginEnd

added in version 22.0.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.

Parameters
lp ViewGroup.MarginLayoutParams: LayoutParams to query

Returns
int the margin along the ending edge in pixels

getMarginStart

added in version 22.0.0
int getMarginStart (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
lp ViewGroup.MarginLayoutParams: LayoutParams to query

Returns
int the margin along the starting edge in pixels

isMarginRelative

added in version 22.0.0
boolean isMarginRelative (ViewGroup.MarginLayoutParams lp)

Check if margins are relative.

Parameters
lp ViewGroup.MarginLayoutParams

Returns
boolean true if either marginStart or marginEnd has been set.

resolveLayoutDirection

added in version 22.0.0
void resolveLayoutDirection (ViewGroup.MarginLayoutParams lp, 
                int layoutDirection)

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

Parameters
lp ViewGroup.MarginLayoutParams

layoutDirection int

setLayoutDirection

added in version 22.0.0
void setLayoutDirection (ViewGroup.MarginLayoutParams lp, 
                int layoutDirection)

Set the layout direction.

Parameters
lp ViewGroup.MarginLayoutParams

layoutDirection int: the layout direction. Should be either LAYOUT_DIRECTION_LTR or LAYOUT_DIRECTION_RTL.

setMarginEnd

added in version 22.0.0
void setMarginEnd (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
lp ViewGroup.MarginLayoutParams: LayoutParams to query

marginEnd int: the desired end margin in pixels

setMarginStart

added in version 22.0.0
void setMarginStart (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
lp ViewGroup.MarginLayoutParams: LayoutParams to query

marginStart int: the desired start margin in pixels

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.