android.support.v4.view
Class MarginLayoutParamsCompat

java.lang.Object
  extended by android.support.v4.view.MarginLayoutParamsCompat

public class MarginLayoutParamsCompat
extends java.lang.Object

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


Constructor Summary
MarginLayoutParamsCompat()
           
 
Method Summary
static int getLayoutDirection(android.view.ViewGroup.MarginLayoutParams lp)
          Retuns the layout direction.
static int getMarginEnd(android.view.ViewGroup.MarginLayoutParams lp)
          Get the relative ending margin that was set.
static int getMarginStart(android.view.ViewGroup.MarginLayoutParams lp)
          Get the relative starting margin that was set.
static boolean isMarginRelative(android.view.ViewGroup.MarginLayoutParams lp)
          Check if margins are relative.
static void resolveLayoutDirection(android.view.ViewGroup.MarginLayoutParams lp, int layoutDirection)
          This will be called by View.requestLayout().
static void setLayoutDirection(android.view.ViewGroup.MarginLayoutParams lp, int layoutDirection)
          Set the layout direction.
static void setMarginEnd(android.view.ViewGroup.MarginLayoutParams lp, int marginEnd)
          Set the relative end margin.
static void setMarginStart(android.view.ViewGroup.MarginLayoutParams lp, int marginStart)
          Set the relative start margin.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MarginLayoutParamsCompat

public MarginLayoutParamsCompat()
Method Detail

getMarginStart

public static int getMarginStart(android.view.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

getMarginEnd

public static int getMarginEnd(android.view.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

setMarginStart

public static void setMarginStart(android.view.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

setMarginEnd

public static void setMarginEnd(android.view.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

isMarginRelative

public static boolean isMarginRelative(android.view.ViewGroup.MarginLayoutParams lp)
Check if margins are relative.

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

getLayoutDirection

public static int getLayoutDirection(android.view.ViewGroup.MarginLayoutParams lp)
Retuns the layout direction. Can be either ViewCompat.LAYOUT_DIRECTION_LTR or ViewCompat.LAYOUT_DIRECTION_RTL.

Returns:
the layout direction.

setLayoutDirection

public static void setLayoutDirection(android.view.ViewGroup.MarginLayoutParams lp,
                                      int layoutDirection)
Set the layout direction.

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

resolveLayoutDirection

public static void resolveLayoutDirection(android.view.ViewGroup.MarginLayoutParams lp,
                                          int layoutDirection)
This will be called by View.requestLayout(). Left and Right margins may be overridden depending on layout direction.