- android
- android.accessibilityservice
- android.accounts
- android.content
- android.database.sqlite
- android.graphics
- android.location
- android.media
- android.net
- android.os
- android.text
- android.view
- android.view.inputmethod
- android.widget
- AbsListView
- AbsoluteLayout
- AbsSeekBar
- AbsSpinner
- AdapterView
- AnalogClock
- BaseAdapter
- BaseExpandableListAdapter
- Button
- CheckBox
- CheckedTextView
- Checkable
- Chronometer
- CompoundButton
- CursorAdapter
- CursorTreeAdapter
- DatePicker
- DialerFilter
- DigitalClock
- EditText
- Filter
- Filter.FilterListener
- Filter.FilterResults
- ExpandableListAdapter
- Filterable
- Gallery
- Gallery.LayoutParams
- GridView
- GridLayout
- RadioGroup
- ImageView
- HorizontalScrollView
- ImageButton
- ImageSwitcher
- FilterQueryProvider
- ListAdapter
- ListView
- MediaController
- QuickContactBadge
- RadioButton
- RatingBar
- RelativeLayout
- RemoteViews
- ResourceCursorAdapter
- ResourceCursorTreeAdapter
- Scroller
- ScrollView
- SearchView
- SeekBar
- SeekBar.OnSeekBarChangeListener
- SimpleAdapter
- SimpleCursorAdapter
- SimpleCursorTreeAdapter
- SimpleExpandableListAdapter
- SlidingDrawer
- Spinner
- SpinnerAdapter
- WrapperListAdapter
- TabHost
- TabHost.TabSpec
- TextView
- TimePicker
- Toast
- TableLayout
- TableRow
- TableRow.LayoutParams
- TabWidget
- TextSwitcher
- ToggleButton
- TwoLineListItem
- VideoView
- ViewAnimator
- ViewFlipper
- ViewSwitcher
- ZoomButtonsController
- ZoomButton
- ZoomControls
- dalvik.system
Gravity
Gravity
版本:Android 4.0 r1
结构
继承关系
public class Gravity extends Object
java.lang.Object
android.view.Gravity
类概述
用来在一个更大容器中布置对象的标准常量和工具。
常量
public static final int AXIS_CLIP
原始位控制右/底边界是否被剪切到它的容器中,基于已应用的对齐方向。
常量值: 8 (0x00000008)
public static final int AXIS_PULL_AFTER
原始位控制右/底边界如何被放置
常量值: 4 (0x00000004)
public static final int AXIS_PULL_BEFORE
原始位控制左/顶边界如何被放置
常量值: 2 (0x00000002)
public static final int AXIS_SPECIFIED
原始位标明一个已指定的轴的对齐方向
常量值: 1 (0x00000001)
public static final int AXIS_X_SHIFT
横轴位定义
常量值: 0 (0x00000000)
public static final int AXIS_Y_SHIFT
垂直轴位定义
常量值: 4 (0x00000004)
public static final int BOTTOM
将对象推至容器底部但不改变它的尺寸
常量值: 80 (0x00000050)
public static final int CENTER
把对象放置于其容器的垂直轴和横轴的中间而不改变其尺寸(译者注:即全居中)
常量值: 17 (0x00000011)
public static final int CENTER_HORIZONTAL
把对象放置于横轴的中间而不改变其尺寸(译者注:水平居中)
常量值: 1 (0x00000001)
public static final int CENTER_VERTICAL
把对象放置于垂直轴的中间而不改变其尺寸(译者注:垂直居中)
常量值: 16 (0x00000010)
public static final int CLIP_HORIZONTAL
标志剪切对象在其容器中沿横轴的边界
常量值: 8 (0x00000008)
public static final int CLIP_VERTICAL
标志裁剪对象在其容器中沿垂直轴的边界
常量值: 128 (0x00000080)
public static final int DISPLAY_CLIP_HORIZONTAL
使裁剪沿水平层面整体显示的特殊常量。这在使用 apply(int, int, int, Rect, int, int, Rect) 的默认情况下是不适用的;你必须自己调用 applyDisplay(int, Rect, Rect) 来做。
常量值: 16777216 (0x01000000)
public static final int DISPLAY_CLIP_VERTICAL
使裁剪沿垂直层面整体显示的特殊常量。这在使用 apply(int, int, int, Rect, int, int, Rect) 的默认情况下是不适用的;你必须通过调用 applyDisplay(int, Rect, Rect) 来做。
常量值: 268435456 (0x10000000)
public static final int END
将对象推至其所在容器的 X 轴的末尾而不改变其尺寸
常量值: 8388613 (0x00800005)
public static final int FILL
拉伸对象的水平和垂直的尺寸以完全填满其所在容器
常量值: 119 (0x00000077)
public static final int FILL_HORIZONTAL
拉伸对象的水平尺寸以完全填满其所在容器(译者注:垂直尺寸不变)
常量值: 7 (0x00000007)
public static final int FILL_VERTICAL
拉伸对象的垂直尺寸以完全填满其所在容器(译者注:水平尺寸不变)
常量值: 112 (0x00000070)
public static final int HORIZONTAL_GRAVITY_MASK
用来得到一个对齐方向的绝对水平对齐方向的二进制掩码。
常量值: 7 (0x00000007)
public static final int LEFT
将对象推至其所在容器的左边而不改变其尺寸
常量值: 3 (0x00000003)
public static final int NO_GRAVITY
用来标明没有设定对齐方向。
常量值: 0 (0x00000000)
public static final int RELATIVE_HORIZONTAL_GRAVITY_MASK
水平对齐方向和脚本的特定方向位的二进制掩码
常量值: 8388615 (0x00800007)
public static final int RELATIVE_LAYOUT_DIRECTION
原始位控制布局方向是否是相对布局(用 START/END 代替绝对布局的 LEFT/RIGHT)
常量值: 8388608 (0x00800000)
public static final int RIGHT
将对象推至其所在容器的右边而不改变其尺寸
常量值: 5 (0x00000005)
public static final int START
将对象推至其所在容器 X 轴起点的位置而不改变其尺寸
常量值: 8388611 (0x00800003)
public static final int TOP
将对象推至其所在容器的顶端而不改变其尺寸
常量值: 48 (0x00000030)
public static final int VERTICAL_GRAVITY_MASK
用来得到一个对齐方向的垂直对齐方向的二进制掩码
常量值: 112 (0x00000070)
公共方法
public static void apply (int gravity, int w, int h, Rect container, Rect outRect)
为一个对象应用一个对齐方向常量
参数
gravity 所需放置的对象,由该类中的常量定义
w 对象的水平尺寸
h 对象的垂直尺寸
container 容器空间的框架,将用来放置指定对象,应该足够大,以包含对象的宽和高。
outRect 接收对象在其容器中的计算帧(computed frame)
public static void apply (int gravity, int w, int h, Rect container, int xAdj, int yAdj, Rect outRect)
为一个对象应用一个对齐方向常量
参数
gravity 所需放置的对象,由该类中的常量定义
w 对象的水平尺寸
h 对象的垂直尺寸
container 容器空间的框架,将用来放置指定对象,应该有足够大,以包含对象的宽和高。
xAdj 应用于 X 轴的偏移,如果对齐方向是 LEFT 那么将对象向右推;如果对齐方向是 RIGHT 那么将对象向左推;如果对齐方向是 CENTER_HORIZONTAL 那么将其向左或右推移;其他情况忽略
yAdj 应用于 Y 轴的偏移,如果对齐方向是 TOP 那么将对象向下推移;如果对齐方向是 BOTTOM 那么将对象向上推移;如果对齐方向是 CENTER_VERTICAL 那么将其向上或下推移;其他情况忽略
outRect 接收对象在其容器中的计算帧(computed frame)
public static void applyDisplay (int gravity, Rect display, Rect inoutObj)
应用于对一个已存在对象整体“显示”的额外对齐方向行为。可用于 apply(int, int, int, Rect, int, int, Rect) 之后来使对象可见.移动或剪切的对象在默认情况下是可见的.对齐方向标志 DISPLAY_CLIP_HORIZONTAL 和 DISPLAY_CLIP_VERTICAL 可用于改变该行为
参数
gravity 用来修改显示中位置的对齐方向常量
display 用来放置对象的矩形显示框
inoutObj 提供当前对象的位置;如果需要适应显示窗则返回已修改后的值
public static boolean isHorizontal (int gravity)
表明提供的对齐方向是否能横向的拉伸。
参数
gravity 待检查的是否能横向的拉伸的对齐方向
返回值
若能横向的拉伸返回真
public static boolean isVertical (int gravity)
表明提供的对齐方向是否能垂直的拉伸。
参数
gravity 待检查是否能垂直的拉伸的对齐方向
返回值
若能垂直拉伸返回真
补充
文章精选
【Android 布局】在程序中设置 android:gravity 和 android:layout_Gravity 属性
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论