MarginLayoutParamsCompat
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 |
static int |
@ReplaceWith(expression = "lp.getMarginEnd()")This method is deprecated. Use |
static int |
@ReplaceWith(expression = "lp.getMarginStart()")This method is deprecated. Use |
static boolean |
@ReplaceWith(expression = "lp.isMarginRelative()")This method is deprecated. Use |
static void |
@ReplaceWith(expression = "lp.resolveLayoutDirection(layoutDirection)")This method is deprecated. Use |
static void |
@ReplaceWith(expression = "lp.setLayoutDirection(layoutDirection)")This method is deprecated. Use |
static void |
@ReplaceWith(expression = "lp.setMarginEnd(marginEnd)")This method is deprecated. Use |
static void |
@ReplaceWith(expression = "lp.setMarginStart(marginStart)")This method is deprecated. Use |
Public methods
public static intgetLayoutDirection(@NonNull ViewGroup.MarginLayoutParams lp)
Returns the layout direction. Can be either LAYOUT_DIRECTION_LTR or LAYOUT_DIRECTION_RTL.
| Returns | |
|---|---|
int |
the layout direction. |
@ReplaceWith(expression = "lp.getMarginEnd()")
public static intgetMarginEnd(@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 |
@ReplaceWith(expression = "lp.getMarginStart()")
public static intgetMarginStart(@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 |
@ReplaceWith(expression = "lp.isMarginRelative()")
public static booleanisMarginRelative(@NonNull ViewGroup.MarginLayoutParams lp)
Check if margins are relative.
| Returns | |
|---|---|
boolean |
true if either marginStart or marginEnd has been set. |
@ReplaceWith(expression = "lp.resolveLayoutDirection(layoutDirection)")
public static voidresolveLayoutDirection(
@NonNull ViewGroup.MarginLayoutParams lp,
int layoutDirection
)
This will be called by requestLayout. Left and Right margins may be overridden depending on layout direction.
@ReplaceWith(expression = "lp.setLayoutDirection(layoutDirection)")
public static voidsetLayoutDirection(
@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 |
@ReplaceWith(expression = "lp.setMarginEnd(marginEnd)")
public static voidsetMarginEnd(@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 |
@ReplaceWith(expression = "lp.setMarginStart(marginStart)")
public static voidsetMarginStart(@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 |