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

GravityCompat

public class GravityCompat extends Object
Compatibility shim for accessing newer functionality from {@link android.view.Gravity}.

Fields Summary
static final GravityCompatImpl
IMPL
public static final int
RELATIVE_LAYOUT_DIRECTION
Raw bit controlling whether the layout direction is relative or not (START/END instead of absolute LEFT/RIGHT).
public static final int
START
Push object to x-axis position at the start of its container, not changing its size.
public static final int
END
Push object to x-axis position at the end of its container, not changing its size.
public static final int
RELATIVE_HORIZONTAL_GRAVITY_MASK
Binary mask for the horizontal gravity and script specific direction bit.
Constructors Summary
Methods Summary
public static voidapply(int gravity, int w, int h, android.graphics.Rect container, android.graphics.Rect outRect, int layoutDirection)
Apply a gravity constant to an object and take care if layout direction is RTL or not.

param
gravity The desired placement of the object, as defined by the constants in this class.
param
w The horizontal size of the object.
param
h The vertical size of the object.
param
container The frame of the containing space, in which the object will be placed. Should be large enough to contain the width and height of the object.
param
outRect Receives the computed frame of the object in its container.
param
layoutDirection The layout direction.
see
ViewCompat#LAYOUT_DIRECTION_LTR
see
ViewCompat#LAYOUT_DIRECTION_RTL


                                                                                                                                                                            
              
                
        IMPL.apply(gravity, w, h, container, outRect, layoutDirection);
    
public static voidapply(int gravity, int w, int h, android.graphics.Rect container, int xAdj, int yAdj, android.graphics.Rect outRect, int layoutDirection)
Apply a gravity constant to an object.

param
gravity The desired placement of the object, as defined by the constants in this class.
param
w The horizontal size of the object.
param
h The vertical size of the object.
param
container The frame of the containing space, in which the object will be placed. Should be large enough to contain the width and height of the object.
param
xAdj Offset to apply to the X axis. If gravity is LEFT this pushes it to the right; if gravity is RIGHT it pushes it to the left; if gravity is CENTER_HORIZONTAL it pushes it to the right or left; otherwise it is ignored.
param
yAdj Offset to apply to the Y axis. If gravity is TOP this pushes it down; if gravity is BOTTOM it pushes it up; if gravity is CENTER_VERTICAL it pushes it down or up; otherwise it is ignored.
param
outRect Receives the computed frame of the object in its container.
param
layoutDirection The layout direction.
see
ViewCompat#LAYOUT_DIRECTION_LTR
see
ViewCompat#LAYOUT_DIRECTION_RTL

        IMPL.apply(gravity, w, h, container, xAdj, yAdj, outRect, layoutDirection);
    
public static voidapplyDisplay(int gravity, android.graphics.Rect display, android.graphics.Rect inoutObj, int layoutDirection)
Apply additional gravity behavior based on the overall "display" that an object exists in. This can be used after {@link android.view.Gravity#apply(int, int, int, Rect, int, int, Rect)} to place the object within a visible display. By default this moves or clips the object to be visible in the display; the gravity flags {@link android.view.Gravity#DISPLAY_CLIP_HORIZONTAL} and {@link android.view.Gravity#DISPLAY_CLIP_VERTICAL} can be used to change this behavior.

param
gravity Gravity constants to modify the placement within the display.
param
display The rectangle of the display in which the object is being placed.
param
inoutObj Supplies the current object position; returns with it modified if needed to fit in the display.
param
layoutDirection The layout direction.
see
ViewCompat#LAYOUT_DIRECTION_LTR
see
ViewCompat#LAYOUT_DIRECTION_RTL

        IMPL.applyDisplay(gravity, display, inoutObj, layoutDirection);
    
public static intgetAbsoluteGravity(int gravity, int layoutDirection)

Convert script specific gravity to absolute horizontal value.

if horizontal direction is LTR, then START will set LEFT and END will set RIGHT. if horizontal direction is RTL, then START will set RIGHT and END will set LEFT.

param
gravity The gravity to convert to absolute (horizontal) values.
param
layoutDirection The layout direction.
return
gravity converted to absolute (horizontal) values.

        return IMPL.getAbsoluteGravity(gravity, layoutDirection);