FileDocCategorySizeDatePackage
MarginLayoutParamsCompat.javaAPI DocAndroid 5.1 API8435Thu Mar 12 22:22:56 GMT 2015android.support.v4.view

MarginLayoutParamsCompat

public class MarginLayoutParamsCompat extends Object
Helper for accessing API features in {@link android.view.ViewGroup.MarginLayoutParams MarginLayoutParams} added after API 4.

Fields Summary
static final MarginLayoutParamsCompatImpl
IMPL
Constructors Summary
Methods Summary
public static intgetLayoutDirection(ViewGroup.MarginLayoutParams lp)
Retuns the layout direction. Can be either {@link ViewCompat#LAYOUT_DIRECTION_LTR} or {@link ViewCompat#LAYOUT_DIRECTION_RTL}.

return
the layout direction.

        return IMPL.getLayoutDirection(lp);
    
public static intgetMarginEnd(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.

param
lp LayoutParams to query
return
the margin along the ending edge in pixels

        return IMPL.getMarginEnd(lp);
    
public static intgetMarginStart(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.

param
lp LayoutParams to query
return
the margin along the starting edge in pixels

        final int version = Build.VERSION.SDK_INT;
        if (version >= 17) { // jb-mr1
            IMPL = new MarginLayoutParamsCompatImplJbMr1();
        } else {
            IMPL = new MarginLayoutParamsCompatImplBase();
        }
    
        return IMPL.getMarginStart(lp);
    
public static booleanisMarginRelative(ViewGroup.MarginLayoutParams lp)
Check if margins are relative.

return
true if either marginStart or marginEnd has been set.

        return IMPL.isMarginRelative(lp);
    
public static voidresolveLayoutDirection(ViewGroup.MarginLayoutParams lp, int layoutDirection)
This will be called by {@link android.view.View#requestLayout()}. Left and Right margins may be overridden depending on layout direction.

        IMPL.resolveLayoutDirection(lp, layoutDirection);
    
public static voidsetLayoutDirection(ViewGroup.MarginLayoutParams lp, int layoutDirection)
Set the layout direction.

param
layoutDirection the layout direction. Should be either {@link ViewCompat#LAYOUT_DIRECTION_LTR} or {@link ViewCompat#LAYOUT_DIRECTION_RTL}.

        IMPL.setLayoutDirection(lp, layoutDirection);
    
public static voidsetMarginEnd(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.

param
lp LayoutParams to query
param
marginEnd the desired end margin in pixels

        IMPL.setMarginEnd(lp, marginEnd);
    
public static voidsetMarginStart(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.

param
lp LayoutParams to query
param
marginStart the desired start margin in pixels

        IMPL.setMarginStart(lp, marginStart);