Most visited

Recently visited

Added in API level 1

Gravity

public class Gravity
extends Object

java.lang.Object
   ↳ android.view.Gravity


用于将对象放置在可能较大的容器内的标准常量和工具。

Summary

Constants

int AXIS_CLIP

根据所应用的重力方向来控制是否将右/下边缘裁剪到其容器中。

int AXIS_PULL_AFTER

原始位控制如何放置右侧/底部边缘。

int AXIS_PULL_BEFORE

原始位控制左/上边缘的放置方式。

int AXIS_SPECIFIED

已指定表示轴重力的原始位。

int AXIS_X_SHIFT

位定义水平轴。

int AXIS_Y_SHIFT

定义垂直轴的位。

int BOTTOM

将对象推到其容器的底部,而不是改变其大小。

int CENTER

将对象放置在其容器中心的垂直和水平轴上,而不是更改其大小。

int CENTER_HORIZONTAL

将对象放置在其容器的水平中心,而不是改变其大小。

int CENTER_VERTICAL

将对象放置在其容器的垂直中心,而不是改变其大小。

int CLIP_HORIZONTAL

标记将对象边缘沿水平轴剪切到其容器。

int CLIP_VERTICAL

标记沿垂直轴将对象的边缘剪切到其容器。

int DISPLAY_CLIP_HORIZONTAL

特殊常量,用于沿水平方向对整体显示进行裁剪。

int DISPLAY_CLIP_VERTICAL

特殊常量,用于沿垂直维度对整体显示进行裁剪。

int END

将对象推送到其容器末端的x轴位置,而不是更改其大小。

int FILL

如果需要,增大对象的水平和垂直尺寸,使其完全填充其容器。

int FILL_HORIZONTAL

如果需要,增大对象的水平尺寸,使其完全填充其容器。

int FILL_VERTICAL

如果需要,增大对象的垂直尺寸,使其完全填充其容器。

int HORIZONTAL_GRAVITY_MASK

二进制掩码来获取重力的绝对水平重力。

int LEFT

将对象推到其容器的左侧,而不是更改其大小。

int NO_GRAVITY

表示没有设置重力的常量

int RELATIVE_HORIZONTAL_GRAVITY_MASK

二进制掩码为水平引力和脚本特定的方向位。

int RELATIVE_LAYOUT_DIRECTION

原始位控制布局方向是否相对(开始/结束,而不是绝对的左/右)。

int RIGHT

将对象推到其容器的右侧,而不是更改其大小。

int START

将对象推送到其容器开始处的x轴位置,而不是更改其大小。

int TOP

将对象推到其容器的顶部,而不是更改其大小。

int VERTICAL_GRAVITY_MASK

二进制掩码来获得重力的垂直重力。

Public constructors

Gravity()

Public methods

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

将重力常数应用于对象。

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

将重力常数应用于对象,并注意布局方向是否为RTL。

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

将重力常数应用于对象。

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

将重力常数应用于对象。

static void applyDisplay(int gravity, Rect display, Rect inoutObj)

根据对象所在的整个“显示”应用额外的重力行为。

static void applyDisplay(int gravity, Rect display, Rect inoutObj, int layoutDirection)

根据对象所在的整个“显示”应用额外的重力行为。

static int getAbsoluteGravity(int gravity, int layoutDirection)

将脚本比重转换为绝对水平值。

static boolean isHorizontal(int gravity)

指示提供的重力是否具有水平拉力。

static boolean isVertical(int gravity)

指示提供的重力是否具有垂直拉力。

Inherited methods

From class java.lang.Object

Constants

AXIS_CLIP

Added in API level 3
int AXIS_CLIP

根据所应用的重力方向来控制是否将右/下边缘裁剪到其容器中。

常量值:8(0x00000008)

AXIS_PULL_AFTER

Added in API level 1
int AXIS_PULL_AFTER

原始位控制如何放置右侧/底部边缘。

常量值:4(0x00000004)

AXIS_PULL_BEFORE

Added in API level 1
int AXIS_PULL_BEFORE

原始位控制左/上边缘的放置方式。

常量值:2(0x00000002)

AXIS_SPECIFIED

Added in API level 1
int AXIS_SPECIFIED

已指定表示轴重力的原始位。

常数值:1(0x00000001)

AXIS_X_SHIFT

Added in API level 1
int AXIS_X_SHIFT

位定义水平轴。

常量值:0(0x00000000)

AXIS_Y_SHIFT

Added in API level 1
int AXIS_Y_SHIFT

定义垂直轴的位。

常量值:4(0x00000004)

BOTTOM

Added in API level 1
int BOTTOM

将对象推到其容器的底部,而不是改变其大小。

常数值:80(0x00000050)

CENTER

Added in API level 1
int CENTER

将对象放置在其容器中心的垂直和水平轴上,而不是更改其大小。

常量值:17(0x00000011)

CENTER_HORIZONTAL

Added in API level 1
int CENTER_HORIZONTAL

将对象放置在其容器的水平中心,而不是改变其大小。

常数值:1(0x00000001)

CENTER_VERTICAL

Added in API level 1
int CENTER_VERTICAL

将对象放置在其容器的垂直中心,而不是改变其大小。

常量值:16(0x00000010)

CLIP_HORIZONTAL

Added in API level 3
int CLIP_HORIZONTAL

标记将对象边缘沿水平轴剪切到其容器。

常量值:8(0x00000008)

CLIP_VERTICAL

Added in API level 3
int CLIP_VERTICAL

标记沿垂直轴将对象的边缘剪切到其容器。

常量值:128(0x00000080)

DISPLAY_CLIP_HORIZONTAL

Added in API level 3
int DISPLAY_CLIP_HORIZONTAL

特殊常量,用于沿水平方向对整体显示进行裁剪。 这在apply(int, int, int, Rect, int, int, Rect)默认情况下不适用; 你必须自己拨打applyDisplay(int, Rect, Rect)

常量值:16777216(0x01000000)

DISPLAY_CLIP_VERTICAL

Added in API level 3
int DISPLAY_CLIP_VERTICAL

特殊常量,用于沿垂直维度对整体显示进行裁剪。 这不是默认应用apply(int, int, int, Rect, int, int, Rect) ; 你必须自己拨打applyDisplay(int, Rect, Rect)

常量值:268435456(0x10000000)

END

Added in API level 14
int END

将对象推送到其容器末端的x轴位置,而不是更改其大小。

常量值:8388613(0x00800005)

FILL

Added in API level 1
int FILL

如果需要,增大对象的水平和垂直尺寸,使其完全填充其容器。

常量值:119(0x00000077)

FILL_HORIZONTAL

Added in API level 1
int FILL_HORIZONTAL

如果需要,增大对象的水平尺寸,使其完全填充其容器。

常量值:7(0x00000007)

FILL_VERTICAL

Added in API level 1
int FILL_VERTICAL

如果需要,增大对象的垂直尺寸,使其完全填充其容器。

常量值:112(0x00000070)

HORIZONTAL_GRAVITY_MASK

Added in API level 1
int HORIZONTAL_GRAVITY_MASK

二进制掩码来获取重力的绝对水平重力。

常量值:7(0x00000007)

LEFT

Added in API level 1
int LEFT

将对象推到其容器的左侧,而不是更改其大小。

常量值:3(0x00000003)

NO_GRAVITY

Added in API level 1
int NO_GRAVITY

表示没有设置重力的常量

常量值:0(0x00000000)

RELATIVE_HORIZONTAL_GRAVITY_MASK

Added in API level 14
int RELATIVE_HORIZONTAL_GRAVITY_MASK

二进制掩码为水平引力和脚本特定的方向位。

常量值:8388615(0x00800007)

RELATIVE_LAYOUT_DIRECTION

Added in API level 14
int RELATIVE_LAYOUT_DIRECTION

原始位控制布局方向是否相对(开始/结束,而不是绝对的左/右)。

常量值:8388608(0x00800000)

RIGHT

Added in API level 1
int RIGHT

将对象推到其容器的右侧,而不是更改其大小。

常量值:5(0x00000005)

START

Added in API level 14
int START

将对象推送到其容器开始处的x轴位置,而不是更改其大小。

常量值:8388611(0x00800003)

TOP

Added in API level 1
int TOP

将对象推到其容器的顶部,而不是更改其大小。

常量值:48(0x00000030)

VERTICAL_GRAVITY_MASK

Added in API level 1
int VERTICAL_GRAVITY_MASK

二进制掩码来获得重力的垂直重力。

常量值:112(0x00000070)

Public constructors

Gravity

Added in API level 1
Gravity ()

Public methods

apply

Added in API level 1
void apply (int gravity, 
                int w, 
                int h, 
                Rect container, 
                int xAdj, 
                int yAdj, 
                Rect outRect)

将重力常数应用于对象。

Parameters
gravity int: The desired placement of the object, as defined by the constants in this class.
w int: The horizontal size of the object.
h int: The vertical size of the object.
container Rect: 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 int: 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 int: 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 Rect: Receives the computed frame of the object in its container.

apply

Added in API level 17
void apply (int gravity, 
                int w, 
                int h, 
                Rect container, 
                Rect outRect, 
                int layoutDirection)

将重力常数应用于对象,并注意布局方向是否为RTL。

Parameters
gravity int: The desired placement of the object, as defined by the constants in this class.
w int: The horizontal size of the object.
h int: The vertical size of the object.
container Rect: 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 Rect: Receives the computed frame of the object in its container.
layoutDirection int: The layout direction.

也可以看看:

apply

Added in API level 17
void apply (int gravity, 
                int w, 
                int h, 
                Rect container, 
                int xAdj, 
                int yAdj, 
                Rect outRect, 
                int layoutDirection)

将重力常数应用于对象。

Parameters
gravity int: The desired placement of the object, as defined by the constants in this class.
w int: The horizontal size of the object.
h int: The vertical size of the object.
container Rect: 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 int: 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 int: 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 Rect: Receives the computed frame of the object in its container.
layoutDirection int: The layout direction.

也可以看看:

apply

Added in API level 1
void apply (int gravity, 
                int w, 
                int h, 
                Rect container, 
                Rect outRect)

将重力常数应用于对象。 这假定布局方向是LTR。

Parameters
gravity int: The desired placement of the object, as defined by the constants in this class.
w int: The horizontal size of the object.
h int: The vertical size of the object.
container Rect: 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 Rect: Receives the computed frame of the object in its container.

applyDisplay

Added in API level 3
void applyDisplay (int gravity, 
                Rect display, 
                Rect inoutObj)

根据对象所在的整体“显示”应用额外的重力行为。在apply(int, int, int, Rect, int, int, Rect)之后可以使用此对象将对象放置在可见的显示内。 默认情况下,这会移动或剪切对象使其在显示中可见; 重力标志DISPLAY_CLIP_HORIZONTALDISPLAY_CLIP_VERTICAL可以用来改变这种行为。

Parameters
gravity int: Gravity constants to modify the placement within the display.
display Rect: The rectangle of the display in which the object is being placed.
inoutObj Rect: Supplies the current object position; returns with it modified if needed to fit in the display.

applyDisplay

Added in API level 17
void applyDisplay (int gravity, 
                Rect display, 
                Rect inoutObj, 
                int layoutDirection)

根据对象所在的整个“显示”应用额外的重力行为。这可以在apply(int, int, int, Rect, int, int, Rect)之后apply(int, int, int, Rect, int, int, Rect) ,将对象放置在可见的显示内。 默认情况下,这会移动或剪切对象使其在显示中可见; 重力标志DISPLAY_CLIP_HORIZONTALDISPLAY_CLIP_VERTICAL可以用来改变这种行为。

Parameters
gravity int: Gravity constants to modify the placement within the display.
display Rect: The rectangle of the display in which the object is being placed.
inoutObj Rect: Supplies the current object position; returns with it modified if needed to fit in the display.
layoutDirection int: The layout direction.

也可以看看:

getAbsoluteGravity

Added in API level 14
int getAbsoluteGravity (int gravity, 
                int layoutDirection)

将脚本比重转换为绝对水平值。

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 int: The gravity to convert to absolute (horizontal) values.
layoutDirection int: The layout direction.
Returns
int gravity converted to absolute (horizontal) values.

isHorizontal

Added in API level 1
boolean isHorizontal (int gravity)

指示提供的重力是否具有水平拉力。

Parameters
gravity int: the gravity to check for horizontal pull
Returns
boolean true if the supplied gravity has an horizontal pull

isVertical

Added in API level 1
boolean isVertical (int gravity)

指示提供的重力是否具有垂直拉力。

Parameters
gravity int: the gravity to check for vertical pull
Returns
boolean true if the supplied gravity has a vertical pull

Hooray!