-
public final class GravityCompat
Compatibility shim for accessing newer functionality from Gravity.
-
-
Field Summary
Fields Modifier and Type Field Description public final static int
RELATIVE_LAYOUT_DIRECTION
public final static int
START
public final static int
END
public final static int
RELATIVE_HORIZONTAL_GRAVITY_MASK
-
Method Summary
Modifier and Type Method Description static void
apply(int gravity, int w, int h, Rect container, Rect outRect, int layoutDirection)
Apply a gravity constant to an object and take care if layout direction is RTL or not. static void
apply(int gravity, int w, int h, Rect container, int xAdj, int yAdj, Rect outRect, int layoutDirection)
Apply a gravity constant to an object. static void
applyDisplay(int gravity, Rect display, Rect inoutObj, int layoutDirection)
Apply additional gravity behavior based on the overall "display" that anobject exists in. static int
getAbsoluteGravity(int gravity, int layoutDirection)
Convert script specific gravity to absolute horizontal value. -
-
Method Detail
-
apply
static void apply(int gravity, int w, int h, Rect container, Rect outRect, int layoutDirection)
Apply a gravity constant to an object and take care if layout direction is RTL or not.
- Parameters:
gravity
- The desired placement of the object, as defined by theconstants in this class.w
- The horizontal size of the object.h
- The vertical size of the object.container
- The frame of the containing space, in which the objectwill be placed.outRect
- Receives the computed frame of the object in itscontainer.layoutDirection
- The layout direction.
-
apply
static void apply(int gravity, int w, int h, Rect container, int xAdj, int yAdj, Rect outRect, int layoutDirection)
Apply a gravity constant to an object.
- Parameters:
gravity
- The desired placement of the object, as defined by theconstants in this class.w
- The horizontal size of the object.h
- The vertical size of the object.container
- The frame of the containing space, in which the objectwill be placed.xAdj
- Offset to apply to the X axis.yAdj
- Offset to apply to the Y axis.outRect
- Receives the computed frame of the object in itscontainer.layoutDirection
- The layout direction.
-
applyDisplay
static void applyDisplay(int gravity, Rect display, Rect inoutObj, int layoutDirection)
Apply additional gravity behavior based on the overall "display" that anobject exists in. This can be used after apply to place the objectwithin a visible display. By default this moves or clips the objectto be visible in the display; the gravity flags DISPLAY_CLIP_HORIZONTAL and DISPLAY_CLIP_VERTICAL can be used to change this behavior.
- Parameters:
gravity
- Gravity constants to modify the placement within thedisplay.display
- The rectangle of the display in which the object isbeing placed.inoutObj
- Supplies the current object position; returns with itmodified if needed to fit in the display.layoutDirection
- The layout direction.
-
getAbsoluteGravity
static int getAbsoluteGravity(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.- Parameters:
gravity
- The gravity to convert to absolute (horizontal) values.layoutDirection
- The layout direction.
-
-
-
-