public static class ViewGroup.MarginLayoutParams
extends ViewGroup.LayoutParams
| java.lang.Object | ||
| android.view.ViewGroup.LayoutParams | ||
| android.view.ViewGroup.MarginLayoutParams | ||
| |
支持边距的布局的每个子布局信息。 有关ViewGroup Margin Layout Attributes支持的所有子视图属性的列表,请参见ViewGroup Margin Layout Attributes 。
XML attributes |
|
|---|---|
android:layout_marginBottom |
Specifies extra space on the bottom side of this view. |
android:layout_marginEnd |
Specifies extra space on the end side of this view. |
android:layout_marginLeft |
Specifies extra space on the left side of this view. |
android:layout_marginRight |
Specifies extra space on the right side of this view. |
android:layout_marginStart |
Specifies extra space on the start side of this view. |
android:layout_marginTop |
Specifies extra space on the top side of this view. |
Inherited XML attributes |
|
|---|---|
android.view.ViewGroup.LayoutParams
|
|
Inherited constants |
|---|
android.view.ViewGroup.LayoutParams
|
Fields |
|
|---|---|
public int |
bottomMargin 子像素的底部边距。 |
public int |
leftMargin 子像素的左边距。 |
public int |
rightMargin 孩子的像素右边距。 |
public int |
topMargin 子像素的顶部边距。 |
Inherited fields |
|---|
android.view.ViewGroup.LayoutParams
|
Public constructors |
|
|---|---|
ViewGroup.MarginLayoutParams(Context c, AttributeSet attrs) 创建一组新的布局参数。 |
|
ViewGroup.MarginLayoutParams(int width, int height) |
|
ViewGroup.MarginLayoutParams(ViewGroup.MarginLayoutParams source) 复制构造函数。 |
|
ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams source) |
|
公共方法(Public methods) |
|
|---|---|
int |
getLayoutDirection() 重新布局方向。 |
int |
getMarginEnd() 以像素为单位返回末端边距。 |
int |
getMarginStart() 以像素为单位返回起始页边距。 |
boolean |
isMarginRelative() 检查边距是否相对。 |
void |
resolveLayoutDirection(int layoutDirection) 这将由 |
void |
setLayoutDirection(int layoutDirection) 设置布局方向 |
void |
setMarginEnd(int end) 设置相对结束边距。 |
void |
setMarginStart(int start) 设置相对起始页边距。 |
void |
setMargins(int left, int top, int right, int bottom) 设置边距,以像素为单位。 |
继承方法(Inherited methods) |
|
|---|---|
android.view.ViewGroup.LayoutParams
|
|
java.lang.Object
|
|
指定此视图底部的额外空间。 这个空间在这个视图的范围之外。 保证金值应该是正值。
必须是一个维度值,它是一个浮点数,后面跟着一个单位,例如“ 14.5sp ”。 可用单位为:px(像素),dp(密度独立像素),sp(基于首选字体大小的缩放像素),单位为英寸,毫米(毫米)。
这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name 。
这对应于全局属性资源符号 layout_marginBottom 。
相关方法:
在此视图的结尾指定额外的空间。 这个空间在这个视图的范围之外。 保证金值应该是正值。
必须是一个维度值,这是一个浮点数,后面跟着一个单位,例如“ 14.5sp ”。 可用单位为:px(像素),dp(密度独立像素),sp(基于首选字体大小的缩放像素),单位为英寸,毫米(毫米)。
这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name 。
这对应于全局属性资源符号 layout_marginEnd 。
相关方法:
指定此视图左侧的额外空间。 这个空间在这个视图的范围之外。 保证金值应该是正值。
必须是尺寸值,这是一个浮点数,后面跟着一个单位,例如“ 14.5sp ”。 可用单位为:px(像素),dp(密度独立像素),sp(基于首选字体大小的缩放像素),单位为英寸,毫米(毫米)。
这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name 。
这对应于全局属性资源符号 layout_marginLeft 。
相关方法:
在此视图的右侧指定额外空间。 这个空间在这个视图的范围之外。 保证金值应该是正值。
必须是维度值,这是一个浮点数,后面跟着一个单位,例如“ 14.5sp ”。 可用单位为:px(像素),dp(密度独立像素),sp(基于首选字体大小的缩放像素),单位为英寸,毫米(毫米)。
这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name 。
这对应于全局属性资源符号 layout_marginRight 。
相关方法:
在该视图的开始侧指定额外的空间。 这个空间在这个视图的范围之外。 保证金值应该是正值。
必须是一个维度值,它是一个浮点数,后面跟着一个单位,例如“ 14.5sp ”。 可用单位为:px(像素),dp(密度独立像素),sp(基于首选字体大小的缩放像素),单位为英寸,毫米(毫米)。
这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name 。
这对应于全局属性资源符号 layout_marginStart 。
相关方法:
在此视图的顶部指定额外的空间。 这个空间在这个视图的范围之外。 保证金值应该是正值。
必须是维度值,这是一个浮点数,后面跟着一个单位,例如“ 14.5sp ”。 可用单位为:px(像素),dp(密度独立像素),sp(基于首选字体大小的缩放像素),单位为英寸,毫米(毫米)。
这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name 。
这对应于全局属性资源符号 layout_marginTop 。
相关方法:
int bottomMargin
子像素的底部边距。 保证金值应该是正值。 在向该字段重新分配新值后,致电setLayoutParams(LayoutParams) 。
int leftMargin
子像素的左边距。 保证金值应该是正值。 重新分配此字段的新值后,致电setLayoutParams(LayoutParams) 。
int rightMargin
孩子的像素右边距。 保证金值应该是正值。 在为此字段重新分配新值后,致电setLayoutParams(LayoutParams) 。
int topMargin
子像素的顶部边距。 保证金值应该是正值。 重新分配此字段的新值后,请setLayoutParams(LayoutParams) 。
ViewGroup.MarginLayoutParams (Context c, AttributeSet attrs)
创建一组新的布局参数。 这些值是从提供的属性集和上下文中提取的。
| 参数(Parameters) | |
|---|---|
c |
Context: the application environment |
attrs |
AttributeSet: the set of attributes from which to extract the layout parameters' values |
ViewGroup.MarginLayoutParams (int width,
int height)
| 参数(Parameters) | |
|---|---|
width |
int
|
height |
int
|
ViewGroup.MarginLayoutParams (ViewGroup.MarginLayoutParams source)
复制构造函数。 克隆源的宽度,高度和边距值。
| 参数(Parameters) | |
|---|---|
source |
ViewGroup.MarginLayoutParams: The layout params to copy from. |
ViewGroup.MarginLayoutParams (ViewGroup.LayoutParams source)
| 参数(Parameters) | |
|---|---|
source |
ViewGroup.LayoutParams
|
int getLayoutDirection ()
重新布局方向。 可以是LAYOUT_DIRECTION_LTR或LAYOUT_DIRECTION_RTL 。
| 返回(Returns) | |
|---|---|
int |
the layout direction. |
int getMarginEnd ()
以像素为单位返回末端边距。
相关XML属性:
| 返回(Returns) | |
|---|---|
int |
the end margin in pixels. |
int getMarginStart ()
以像素为单位返回起始页边距。
相关XML属性:
| 返回(Returns) | |
|---|---|
int |
the start margin in pixels. |
boolean isMarginRelative ()
检查边距是否相对。
相关XML属性:
| 返回(Returns) | |
|---|---|
boolean |
true if either marginStart or marginEnd has been set. |
void resolveLayoutDirection (int layoutDirection)
这将由requestLayout() 。 根据布局方向,左右边距可能会被覆盖。
| 参数(Parameters) | |
|---|---|
layoutDirection |
int: the direction of the layout LAYOUT_DIRECTION_LTR LAYOUT_DIRECTION_RTL |
void setLayoutDirection (int layoutDirection)
设置布局方向
| 参数(Parameters) | |
|---|---|
layoutDirection |
int: the layout direction. Should be either LAYOUT_DIRECTION_LTR or LAYOUT_DIRECTION_RTL. |
void setMarginEnd (int end)
设置相对结束边距。 保证金值应该是正值。
相关XML属性:
| 参数(Parameters) | |
|---|---|
end |
int: the end margin size |
void setMarginStart (int start)
设置相对起始页边距。 保证金值应该是正值。
相关XML属性:
| 参数(Parameters) | |
|---|---|
start |
int: the start margin size |
void setMargins (int left,
int top,
int right,
int bottom)
设置边距,以像素为单位。 需要拨打requestLayout() ,以便考虑新的保证金。 取决于布局方向,左右边距可能会被requestLayout()覆盖。 保证金值应该是正值。
相关XML属性:
| 参数(Parameters) | |
|---|---|
left |
int: the left margin size |
top |
int: the top margin size |
right |
int: the right margin size |
bottom |
int: the bottom margin size |