ディレクトリ 検索
android Manifest Manifest.permission Manifest.permission_group android.accessibilityservice AccessibilityService android.accounts Account android.app NotificationManager android.bluetooth BluetoothAdapter BluetoothClass BluetoothClass.Device BluetoothClass.Device.Major BluetoothClass.Service BluetoothDevice BluetoothServerSocket BluetoothSocket android.content SharedPreferences android.database.sqlite SQLiteCursorDriver SQLiteOpenHelper android.graphics Bitmap android.location LocationListener Geocoder GpsStatus GpsStatus.Listener GpsStatus.NmeaListener GpsSatellite android.media AudioFormat AsyncPlayer AudioRecord AudioRecord.OnRecordPositionUpdateListener ThumbnailUtils AudioManager android.net TrafficStats MailTo LocalSocket android.os AsyncTask AsyncTask.Status CountDownTimer Message MessageQueue HandlerThread android.text Html android.util JsonWriter android.view ContextMenu ContextMenu.ContextMenuInfo Display ViewManager View ViewStub ViewTreeObserver ViewParent WindowManager GestureDetector Gravity MenuInflater ScaleGestureDetector SoundEffectConstants android.view.inputmethod InputConnection InputMethod InputMethodSession BaseInputConnection InputMethodManager android.widget AbsListView AbsListView.LayoutParams AbsListView.OnScrollListener AbsListView.RecyclerListener AbsoluteLayout AbsoluteLayout.LayoutParams AbsSeekBar AbsSpinner AdapterView AdapterView.AdapterContextMenuInfo AdapterView.OnItemLongClickListener AdapterView.OnItemSelectedListener AdapterView.OnItemClickListener AnalogClock BaseAdapter BaseExpandableListAdapter Button CheckBox CheckedTextView Checkable Chronometer Chronometer.OnChronometerTickListener CompoundButton CompoundButton.OnCheckedChangeListener CursorAdapter CursorTreeAdapter DatePicker DatePicker.OnDateChangedListener DialerFilter DigitalClock EditText Filter Filter.FilterListener Filter.FilterResults ExpandableListAdapter ExpandableListView.OnChildClickListener ExpandableListView.OnGroupClickListener ExpandableListView.OnGroupCollapseListener ExpandableListView.OnGroupExpandListener Filterable Gallery Gallery.LayoutParams GridView GridLayout GridLayout.Alignment RadioGroup ImageView ImageView.ScaleType HorizontalScrollView ImageButton ImageSwitcher FilterQueryProvider ListAdapter ListView MediaController MultiAutoCompleteTextView MultiAutoCompleteTextView.CommaTokenizer MultiAutoCompleteTextView.Tokenizer QuickContactBadge RadioButton RatingBar RatingBar.OnRatingBarChangeListener RelativeLayout RemoteViews ResourceCursorAdapter ResourceCursorTreeAdapter Scroller ScrollView SearchView SearchView.OnCloseListener SearchView.OnQueryTextListener SearchView.OnSuggestionListener SeekBar SeekBar.OnSeekBarChangeListener SimpleAdapter SimpleAdapter.ViewBinder SimpleCursorAdapter SimpleCursorAdapter.CursorToStringConverter SimpleCursorAdapter.ViewBinder SimpleCursorTreeAdapter SimpleCursorTreeAdapter.ViewBinder SimpleExpandableListAdapter SlidingDrawer SlidingDrawer.OnDrawerCloseListener SlidingDrawer.OnDrawerOpenListener SlidingDrawer.OnDrawerScrollListener Spinner SpinnerAdapter WrapperListAdapter TabHost TabHost.TabSpec TextView TimePicker TimePicker.OnTimeChangedListener Toast TableLayout TableLayout.LayoutParams TableRow TableRow.LayoutParams TabWidget TextSwitcher ToggleButton TwoLineListItem VideoView ViewAnimator ViewFlipper ViewSwitcher ViewSwitcher.ViewFactory ZoomButtonsController ZoomButtonsController.OnZoomListener ZoomButton ZoomControls dalvik.system DexFile
テキスト


Gravity

版本:Android 4.0 r1

结构

继承关系

public classGravityextendsObject

java.lang.Object

android.view.Gravity

类概述

用来在一个更大容器中布置对象的标准常量和工具。

常量

public static final intAXIS_CLIP

原始位控制右/底边界是否被剪切到它的容器中,基于已应用的对齐方向。

常量值: 8 (0x00000008)

public static final intAXIS_PULL_AFTER

原始位控制右/底边界如何被放置

常量值: 4 (0x00000004)

public static final intAXIS_PULL_BEFORE

原始位控制左/顶边界如何被放置

常量值: 2 (0x00000002)

public static final intAXIS_SPECIFIED

原始位标明一个已指定的轴的对齐方向

常量值: 1 (0x00000001)

public static final intAXIS_X_SHIFT

横轴位定义

常量值: 0 (0x00000000)

public static final intAXIS_Y_SHIFT

垂直轴位定义

常量值: 4 (0x00000004)

public static final intBOTTOM

将对象推至容器底部但不改变它的尺寸

常量值: 80 (0x00000050)

public static final intCENTER

把对象放置于其容器的垂直轴和横轴的中间而不改变其尺寸(译者注:即全居中)

常量值: 17 (0x00000011)

public static final intCENTER_HORIZONTAL

把对象放置于横轴的中间而不改变其尺寸(译者注:水平居中)

常量值: 1 (0x00000001)

public static final intCENTER_VERTICAL

把对象放置于垂直轴的中间而不改变其尺寸(译者注:垂直居中)

常量值: 16 (0x00000010)

public static final intCLIP_HORIZONTAL

标志剪切对象在其容器中沿横轴的边界

常量值: 8 (0x00000008)

public static final intCLIP_VERTICAL

标志裁剪对象在其容器中沿垂直轴的边界

常量值: 128 (0x00000080)

public static final intDISPLAY_CLIP_HORIZONTAL

使裁剪沿水平层面整体显示的特殊常量。这在使用apply(int, int, int, Rect, int, int, Rect)的默认情况下是不适用的;你必须自己调用applyDisplay(int, Rect, Rect)来做。

常量值: 16777216 (0x01000000)

public static final intDISPLAY_CLIP_VERTICAL

使裁剪沿垂直层面整体显示的特殊常量。这在使用apply(int, int, int, Rect, int, int, Rect)的默认情况下是不适用的;你必须通过调用applyDisplay(int, Rect, Rect)来做。

常量值: 268435456 (0x10000000)

public static final intEND

将对象推至其所在容器的X轴的末尾而不改变其尺寸

常量值: 8388613 (0x00800005)

public static final intFILL

拉伸对象的水平和垂直的尺寸以完全填满其所在容器

常量值: 119 (0x00000077)

public static final intFILL_HORIZONTAL

拉伸对象的水平尺寸以完全填满其所在容器(译者注:垂直尺寸不变)

常量值: 7 (0x00000007)

public static final intFILL_VERTICAL

拉伸对象的垂直尺寸以完全填满其所在容器(译者注:水平尺寸不变)

常量值: 112 (0x00000070)

public static final intHORIZONTAL_GRAVITY_MASK

用来得到一个对齐方向的绝对水平对齐方向的二进制掩码。

常量值: 7 (0x00000007)

public static final intLEFT

将对象推至其所在容器的左边而不改变其尺寸

常量值: 3 (0x00000003)

public static final intNO_GRAVITY

用来标明没有设定对齐方向。

常量值: 0 (0x00000000)

public static final intRELATIVE_HORIZONTAL_GRAVITY_MASK

水平对齐方向和脚本的特定方向位的二进制掩码

常量值: 8388615 (0x00800007)

public static final intRELATIVE_LAYOUT_DIRECTION

原始位控制布局方向是否是相对布局(用START/END代替绝对布局的LEFT/RIGHT

常量值: 8388608 (0x00800000)

public static final intRIGHT

将对象推至其所在容器的右边而不改变其尺寸

常量值: 5 (0x00000005)

public static final intSTART

将对象推至其所在容器X轴起点的位置而不改变其尺寸

常量值: 8388611 (0x00800003)

public static final intTOP

将对象推至其所在容器的顶端而不改变其尺寸

常量值: 48 (0x00000030)

public static final intVERTICAL_GRAVITY_MASK

用来得到一个对齐方向的垂直对齐方向的二进制掩码

常量值: 112 (0x00000070)

公共方法

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

为一个对象应用一个对齐方向常量

参数

gravity所需放置的对象,由该类中的常量定义

w对象的水平尺寸

h对象的垂直尺寸

container容器空间的框架,将用来放置指定对象,应该足够大,以包含对象的宽和高。

outRect接收对象在其容器中的计算帧(computed frame)

public static voidapply(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 voidapplyDisplay(int gravity, Rect display, Rect inoutObj)

应用于对一个已存在对象整体“显示”的额外对齐方向行为。可用于apply(int, int, int, Rect, int, int, Rect)之后来使对象可见.移动或剪切的对象在默认情况下是可见的.对齐方向标志DISPLAY_CLIP_HORIZONTALDISPLAY_CLIP_VERTICAL可用于改变该行为

参数

gravity用来修改显示中位置的对齐方向常量

display用来放置对象的矩形显示框

inoutObj提供当前对象的位置;如果需要适应显示窗则返回已修改后的值

public static booleanisHorizontal(int gravity)

表明提供的对齐方向是否能横向的拉伸。

参数

gravity待检查的是否能横向的拉伸的对齐方向

返回值

若能横向的拉伸返回真

public static booleanisVertical(int gravity)

表明提供的对齐方向是否能垂直的拉伸。

参数

gravity待检查是否能垂直的拉伸的对齐方向

返回值

若能垂直拉伸返回真

补充

文章精选

Android布局】在程序中设置android:gravityandroid:layout_Gravity属性

android:layout_gravityandroid:gravity的区别


前の記事: 次の記事: