Android(安卓)UI 中 gravity 与 layout_gravity 参数
16lz
2021-12-04
gravity 与 layout_gravity 的区别
android:gravity
sets the gravity of the content of the View its used on.
android:layout_gravity
sets the gravity of the View or Layout in its parent.
简单来说就是
- android:gravity - 控件内部子控件的位置
- android:layout_gravity - 在父控件中所处的位置
注意
Must be one or more (separated by '|
') of the following constant values.
Constant | Value | Description |
---|---|---|
top | 0x30 | Push object to the top of its container, not changing its size. |
bottom | 0x50 | Push object to the bottom of its container, not changing its size. |
left | 0x03 | Push object to the left of its container, not changing its size. |
right | 0x05 | Push object to the right of its container, not changing its size. |
center_vertical | 0x10 | Place object in the vertical center of its container, not changing its size. |
fill_vertical | 0x70 | Grow the vertical size of the object if needed so it completely fills its container. |
center_horizontal | 0x01 | Place object in the horizontal center of its container, not changing its size. |
fill_horizontal | 0x07 | Grow the horizontal size of the object if needed so it completely fills its container. |
center | 0x11 | Place the object in the center of its container in both the vertical and horizontal axis, not changing its size. |
fill | 0x77 | Grow the horizontal and vertical size of the object if needed so it completely fills its container. |
clip_vertical | 0x80 | Additional option that can be set to have the top and/or bottom edges of the child clipped to its container's bounds. The clip will be based on the vertical gravity: a top gravity will clip the bottom edge, a bottom gravity will clip the top edge, and neither will clip both edges. |
clip_horizontal | 0x08 | Additional option that can be set to have the left and/or right edges of the child clipped to its container's bounds. The clip will be based on the horizontal gravity: a left gravity will clip the right edge, a right gravity will clip the left edge, and neither will clip both edges. |
start | 0x00800003 | Push object to the beginning of its container, not changing its size. |
end | 0x00800005 | Push object to the end of its container, not changing its size. |
更多相关文章
- Android(安卓)日期控件的简单实现
- android 分段显示文本颜色控件
- Android控件属性集锦
- Android学习--TextView和Button
- Android(安卓)两个可拖动的SeekBar 两点拖动
- android app content
- android学习之textView布局文件
- android2.x中android:layout_marginRight不起作用的解决办法
- 时钟控件AnalogClock和DigitalClock