Android
android.view
public class

android.view.Gravity

java.lang.Object
android.view.Gravity

Standard constants and tools for placing an object within a potentially larger container.

Summary

Constants

      Value  
int  AXIS_PULL_AFTER  Raw bit controlling how the right/bottom edge is placed.  0x00000004 
int  AXIS_PULL_BEFORE  Raw bit controlling how the left/top edge is placed.  0x00000002 
int  AXIS_SPECIFIED  Raw bit indicating the gravity for an axis has been specified.  0x00000001 
int  AXIS_X_SHIFT  Bits defining the horizontal axis.  0x00000000 
int  AXIS_Y_SHIFT  Bits defining the vertical axis.  0x00000004 
int  BOTTOM  Push object to the bottom of its container, not changing its size.  80  0x00000050 
int  CENTER  Place the object in the center of its container in both the vertical and horizontal axis, not changing its size.  17  0x00000011 
int  CENTER_HORIZONTAL  Place object in the horizontal center of its container, not changing its size.  0x00000001 
int  CENTER_VERTICAL  Place object in the vertical center of its container, not changing its size.  16  0x00000010 
int  FILL  Grow the horizontal and vertical size of the obejct if needed so it completely fills its container.  119  0x00000077 
int  FILL_HORIZONTAL  Grow the horizontal size of the object if needed so it completely fills its container.  0x00000007 
int  FILL_VERTICAL  Grow the vertical size of the object if needed so it completely fills its container.  112  0x00000070 
int  HORIZONTAL_GRAVITY_MASK  Binary mask to get the horizontal gravity of a gravity.  0x00000007 
int  LEFT  Push object to the left of its container, not changing its size.  0x00000003 
int  NO_GRAVITY  Contstant indicating that no gravity has been set   0x00000000 
int  RIGHT  Push object to the right of its container, not changing its size.  0x00000005 
int  TOP  Push object to the top of its container, not changing its size.  48  0x00000030 
int  VERTICAL_GRAVITY_MASK  Binary mask to get the vertical gravity of a gravity.  112  0x00000070 

Public Constructors

            Gravity()

Public Methods

      static    void  apply(int gravity, int w, int h, Rect container, Rect outRect)
Apply a gravity constant to an object.
      static    void  apply(int gravity, int w, int h, Rect container, int xAdj, int yAdj, Rect outRect)
Apply a gravity constant to an object.
      static    boolean  isHorizontal(int gravity)

Indicate whether the supplied gravity has an horizontal pull.

      static    boolean  isVertical(int gravity)

Indicate whether the supplied gravity has a vertical pull.

Methods inherited from class java.lang.Object

Details

Constants

public static final int AXIS_PULL_AFTER

Raw bit controlling how the right/bottom edge is placed.
Constant Value: 4 (0x00000004)

public static final int AXIS_PULL_BEFORE

Raw bit controlling how the left/top edge is placed.
Constant Value: 2 (0x00000002)

public static final int AXIS_SPECIFIED

Raw bit indicating the gravity for an axis has been specified.
Constant Value: 1 (0x00000001)

public static final int AXIS_X_SHIFT

Bits defining the horizontal axis.
Constant Value: 0 (0x00000000)

public static final int AXIS_Y_SHIFT

Bits defining the vertical axis.
Constant Value: 4 (0x00000004)

public static final int BOTTOM

Push object to the bottom of its container, not changing its size.
Constant Value: 80 (0x00000050)

public static final int CENTER

Place the object in the center of its container in both the vertical and horizontal axis, not changing its size.
Constant Value: 17 (0x00000011)

public static final int CENTER_HORIZONTAL

Place object in the horizontal center of its container, not changing its size.
Constant Value: 1 (0x00000001)

public static final int CENTER_VERTICAL

Place object in the vertical center of its container, not changing its size.
Constant Value: 16 (0x00000010)

public static final int FILL

Grow the horizontal and vertical size of the obejct if needed so it completely fills its container.
Constant Value: 119 (0x00000077)

public static final int FILL_HORIZONTAL

Grow the horizontal size of the object if needed so it completely fills its container.
Constant Value: 7 (0x00000007)

public static final int FILL_VERTICAL

Grow the vertical size of the object if needed so it completely fills its container.
Constant Value: 112 (0x00000070)

public static final int HORIZONTAL_GRAVITY_MASK

Binary mask to get the horizontal gravity of a gravity.
Constant Value: 7 (0x00000007)

public static final int LEFT

Push object to the left of its container, not changing its size.
Constant Value: 3 (0x00000003)

public static final int NO_GRAVITY

Contstant indicating that no gravity has been set
Constant Value: 0 (0x00000000)

public static final int RIGHT

Push object to the right of its container, not changing its size.
Constant Value: 5 (0x00000005)

public static final int TOP

Push object to the top of its container, not changing its size.
Constant Value: 48 (0x00000030)

public static final int VERTICAL_GRAVITY_MASK

Binary mask to get the vertical gravity of a gravity.
Constant Value: 112 (0x00000070)

Public Constructors

public Gravity()

Public Methods

public static void apply(int gravity, int w, int h, Rect container, Rect outRect)

Apply a gravity constant to an object.

Parameters

gravity The desired placement of the object, as defined by the constants 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 object will be placed. Should be large enough to contain the width and height of the object.
outRect Receives the computed frame of the object in its container.

public static void apply(int gravity, int w, int h, Rect container, int xAdj, int yAdj, Rect outRect)

Apply a gravity constant to an object.

Parameters

gravity The desired placement of the object, as defined by the constants 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 object will be placed. Should be large enough to contain the width and height of the object.
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.
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.
outRect Receives the computed frame of the object in its container.

public static boolean isHorizontal(int gravity)

Indicate whether the supplied gravity has an horizontal pull.

Parameters

gravity the gravity to check for horizontal pull

Returns

  • true if the supplied gravity has an horizontal pull

public static boolean isVertical(int gravity)

Indicate whether the supplied gravity has a vertical pull.

Parameters

gravity the gravity to check for vertical pull

Returns

  • true if the supplied gravity has a vertical pull
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56