to top
Android APIs
public class

MarginLayoutParamsCompat

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

Class Overview

Helper for accessing API features in MarginLayoutParams added after API 4.

Summary

Public Constructors
MarginLayoutParamsCompat()
Public Methods
static int getLayoutDirection(ViewGroup.MarginLayoutParams lp)
Retuns 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.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public MarginLayoutParamsCompat ()

Public Methods

public static int getLayoutDirection (ViewGroup.MarginLayoutParams lp)

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

Returns
  • the layout direction.

public static 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 LayoutParams to query
Returns
  • the margin along the ending edge in pixels

public static 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 LayoutParams to query
Returns
  • the margin along the starting edge in pixels

public static boolean isMarginRelative (ViewGroup.MarginLayoutParams lp)

Check if margins are relative.

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

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

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

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

Set the layout direction.

Parameters
layoutDirection the layout direction. Should be either LAYOUT_DIRECTION_LTR or LAYOUT_DIRECTION_RTL.

public static 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 LayoutParams to query
marginEnd the desired end margin in pixels

public static 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 LayoutParams to query
marginStart the desired start margin in pixels