public static class RelativeLayout.LayoutParams
extends ViewGroup.MarginLayoutParams
| java.lang.Object | |||
| android.view.ViewGroup.LayoutParams | |||
| android.view.ViewGroup.MarginLayoutParams | |||
| android.widget.RelativeLayout.LayoutParams | |||
| |
与RelativeLayout相关联的每个孩子的布局信息。
XML attributes |
|
|---|---|
android:layout_above |
Positions the bottom edge of this view above the given anchor view ID. |
android:layout_alignBaseline |
Positions the baseline of this view on the baseline of the given anchor view ID. |
android:layout_alignBottom |
Makes the bottom edge of this view match the bottom edge of the given anchor view ID. |
android:layout_alignEnd |
Makes the end edge of this view match the end edge of the given anchor view ID. |
android:layout_alignLeft |
Makes the left edge of this view match the left edge of the given anchor view ID. |
android:layout_alignParentBottom |
If true, makes the bottom edge of this view match the bottom edge of the parent. |
android:layout_alignParentEnd |
If true, makes the end edge of this view match the end edge of the parent. |
android:layout_alignParentLeft |
If true, makes the left edge of this view match the left edge of the parent. |
android:layout_alignParentRight |
If true, makes the right edge of this view match the right edge of the parent. |
android:layout_alignParentStart |
If true, makes the start edge of this view match the start edge of the parent. |
android:layout_alignParentTop |
If true, makes the top edge of this view match the top edge of the parent. |
android:layout_alignRight |
Makes the right edge of this view match the right edge of the given anchor view ID. |
android:layout_alignStart |
Makes the start edge of this view match the start edge of the given anchor view ID. |
android:layout_alignTop |
Makes the top edge of this view match the top edge of the given anchor view ID. |
android:layout_alignWithParentIfMissing |
If set to true, the parent will be used as the anchor when the anchor cannot be be found for layout_toLeftOf, layout_toRightOf, etc. |
android:layout_below |
Positions the top edge of this view below the given anchor view ID. |
android:layout_centerHorizontal |
If true, centers this child horizontally within its parent. |
android:layout_centerInParent |
If true, centers this child horizontally and vertically within its parent. |
android:layout_centerVertical |
If true, centers this child vertically within its parent. |
android:layout_toEndOf |
Positions the start edge of this view to the end of the given anchor view ID. |
android:layout_toLeftOf |
Positions the right edge of this view to the left of the given anchor view ID. |
android:layout_toRightOf |
Positions the left edge of this view to the right of the given anchor view ID. |
android:layout_toStartOf |
Positions the end edge of this view to the start of the given anchor view ID. |
Inherited XML attributes |
|
|---|---|
android.view.ViewGroup.MarginLayoutParams
|
|
android.view.ViewGroup.LayoutParams
|
|
Inherited constants |
|---|
android.view.ViewGroup.LayoutParams
|
Fields |
|
|---|---|
public boolean |
alignWithParent 当为true时,如果该锚点不存在或锚点的可见性为GONE,则使用父类作为锚点。 |
Inherited fields |
|---|
android.view.ViewGroup.MarginLayoutParams
|
android.view.ViewGroup.LayoutParams
|
Public constructors |
|
|---|---|
RelativeLayout.LayoutParams(Context c, AttributeSet attrs) |
|
RelativeLayout.LayoutParams(int w, int h) |
|
RelativeLayout.LayoutParams(ViewGroup.LayoutParams source) |
|
RelativeLayout.LayoutParams(ViewGroup.MarginLayoutParams source) |
|
RelativeLayout.LayoutParams(RelativeLayout.LayoutParams source) 复制构造函数。 |
|
公共方法(Public methods) |
|
|---|---|
void |
addRule(int verb, int subject) 添加要由RelativeLayout解释的布局规则。 |
void |
addRule(int verb) 添加要由RelativeLayout解释的布局规则。 |
String |
debug(String output) 返回此组布局参数的字符串表示形式。 |
int |
getRule(int verb) 返回与特定动词关联的布局规则。 |
int[] |
getRules() 检索所有受支持规则的完整列表,其中索引是规则谓词,元素值是指定的值;如果未设置,则检索“false”。 |
void |
removeRule(int verb) 删除由RelativeLayout解释的布局规则。 |
void |
resolveLayoutDirection(int layoutDirection) 这将由 |
继承方法(Inherited methods) |
|
|---|---|
android.view.ViewGroup.MarginLayoutParams
|
|
android.view.ViewGroup.LayoutParams
|
|
java.lang.Object
|
|
将此视图的底部边缘定位在给定锚点视图ID上方。 容纳此视图的底部边距和锚点视图的顶部边距。
必须是另一个资源的引用,其形式为“ @[+][package:]type:name ”,或者其形式为“一个主题属性 ?[package:][type:]name ”。
这对应于全局属性资源符号 layout_above 。
将此视图的基线定位到给定锚点视图ID的基线上。
必须是另一个资源的引用,其形式为“ @[+][package:]type:name ”,或者其形式为“一个主题属性 ?[package:][type:]name ”。
这对应于全局属性资源符号 layout_alignBaseline 。
使该视图的底部边缘与给定锚点视图ID的底部边缘相匹配。 容纳底部边缘。
必须是另一个资源的引用,其形式为“ @[+][package:]type:name ”,或者其形式为“一个主题属性 ?[package:][type:]name ”。
这对应于全局属性资源符号 layout_alignBottom 。
使此视图的结束边缘与给定的锚点视图ID的结束边缘相匹配。 适应末端利润。
必须是另一个资源的引用,其形式为“ @[+][package:]type:name ”,或者其形式为“一个主题属性 ?[package:][type:]name ”。
这对应于全局属性资源符号 layout_alignEnd 。
使此视图的左边缘与给定锚点视图ID的左边缘匹配。 容纳左边距。
必须是另一个资源的引用,其形式为“ @[+][package:]type:name ”,或者其形式为“一个主题属性 ?[package:][type:]name ”。
这对应于全局属性资源符号 layout_alignLeft 。
如果为true,则使该视图的底部边缘与父项的底部边缘匹配。 容纳底部边缘。
必须是布尔值,可以是“ true ”或“ false ”。
这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name 。
这对应于全局属性资源符号 layout_alignParentBottom 。
如果为true,则使该视图的结束边与父项的结束边相匹配。 适应末端利润。
必须是布尔值,“ true ”或“ false ”。
这也可能是对包含此类型值的资源(格式为“ @[package:]type:name ”)或主题属性(格式为“ ?[package:][type:]name ”)的 ?[package:][type:]name 。
这对应于全局属性资源符号 layout_alignParentEnd 。
如果为true,则使该视图的左边缘与父项的左边缘匹配。 容纳左边距。
必须是布尔值,“ true ”或“ false ”。
这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name 。
这对应于全局属性资源符号 layout_alignParentLeft 。
如果为true,则使该视图的右边缘与父项的右边缘匹配。 容纳右边距。
必须是布尔值,可以是“ true ”或“ false ”。
这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name 。
这对应于全局属性资源符号 layout_alignParentRight 。
如果为true,则使该视图的起始边缘与父项的起始边缘匹配。 容纳开始保证金。
必须是布尔值,“ true ”或“ false ”。
这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name 。
这对应于全局属性资源符号 layout_alignParentStart 。
如果为true,则使该视图的顶部边缘与父级的顶部边缘匹配。 容纳顶部边缘。
必须是布尔值,即“ true ”或“ false ”。
这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name 。
这对应于全局属性资源符号 layout_alignParentTop 。
使此视图的右边缘与给定锚点视图ID的右边缘匹配。 容纳右边距。
必须是另一个资源的引用,其形式为“ @[+][package:]type:name ”,或者其形式为“一个主题属性 ?[package:][type:]name ”。
这对应于全局属性资源符号 layout_alignRight 。
使此视图的起始边缘与给定锚点视图ID的起始边缘相匹配。 容纳开始保证金。
必须是另一个资源的引用,其形式为“ @[+][package:]type:name ”,或者其形式为“一个主题属性 ?[package:][type:]name ”。
这对应于全局属性资源符号 layout_alignStart 。
使此视图的顶部边缘与给定锚点视图ID的顶部边缘匹配。 容纳顶部边缘。
必须是另一个资源的引用,其形式为“ @[+][package:]type:name ”,或者其形式为“一个主题属性 ?[package:][type:]name ”。
这对应于全局属性资源符号 layout_alignTop 。
如果设置为true,则当找不到对于layout_toLeftOf,layout_toRightOf等的锚点时,父级将用作锚点。
必须是布尔值,可以是“ true ”或“ false ”。
这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name 。
这对应于全局属性资源符号 layout_alignWithParentIfMissing 。
将此视图的顶部边缘放置在给定锚点视图ID下方。 容纳此视图的顶部边距和锚点视图的底部边距。
必须是另一个资源的引用,其形式为“ @[+][package:]type:name ”,或者其形式为“一个主题属性 ?[package:][type:]name ”。
这对应于全局属性资源符号 layout_below 。
如果为true,则将此孩子水平居中在其父代中。
必须是布尔值,“ true ”或“ false ”。
这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name 。
这对应于全局属性资源符号 layout_centerHorizontal 。
如果为true,则将此孩子在其父代中水平和垂直居中。
必须是布尔值,可以是“ true ”或“ false ”。
这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name 。
这对应于全局属性资源符号 layout_centerInParent 。
如果为true,则将此孩子垂直居中在其父代中。
必须是布尔值,可以是“ true ”或“ false ”。
这也可能是对包含此类型值的资源(形式为“ @[package:]type:name ”)或主题属性(形式为“ ?[package:][type:]name ”)的 ?[package:][type:]name 。
这对应于全局属性资源符号 layout_centerVertical 。
将此视图的起始边缘定位到给定锚点视图ID的结尾处。 容纳此视图的起始页边距并结束锚视图的边距。
必须是另一个资源的引用,其形式为“ @[+][package:]type:name ”,或者其形式为“一个主题属性 ?[package:][type:]name ”。
这对应于全局属性资源符号 layout_toEndOf 。
将此视图的右边缘定位到给定锚点视图ID的左侧。 容纳此视图的右边距并留下锚点视图的边距。
必须是另一个资源的引用,其形式为“ @[+][package:]type:name ”,或者其形式为“一个主题属性 ?[package:][type:]name ”。
这对应于全局属性资源符号 layout_toLeftOf 。
将此视图的左边缘定位到给定锚点视图ID的右侧。 容纳此视图的左边界和锚点视图的右边界。
必须是另一个资源的引用,其形式为“ @[+][package:]type:name ”,或者其形式为“一个主题属性 ?[package:][type:]name ”。
这对应于全局属性资源符号 layout_toRightOf 。
将此视图的结束边缘定位到给定锚点视图ID的开始位置。 适应此视图的结束边界并启动锚视图的边距。
必须是另一个资源的引用,其形式为“ @[+][package:]type:name ”,或者其形式为“一个主题属性 ?[package:][type:]name ”。
这对应于全局属性资源符号 layout_toStartOf 。
boolean alignWithParent
当为true时,如果该锚点不存在或锚点的可见性为GONE,则使用父类作为锚点。
RelativeLayout.LayoutParams (Context c, AttributeSet attrs)
| 参数(Parameters) | |
|---|---|
c |
Context
|
attrs |
AttributeSet
|
RelativeLayout.LayoutParams (int w,
int h)
| 参数(Parameters) | |
|---|---|
w |
int
|
h |
int
|
RelativeLayout.LayoutParams (ViewGroup.LayoutParams source)
| 参数(Parameters) | |
|---|---|
source |
ViewGroup.LayoutParams
|
RelativeLayout.LayoutParams (ViewGroup.MarginLayoutParams source)
| 参数(Parameters) | |
|---|---|
source |
ViewGroup.MarginLayoutParams
|
RelativeLayout.LayoutParams (RelativeLayout.LayoutParams source)
复制构造函数。 克隆源的宽度,高度,边距值和规则。
| 参数(Parameters) | |
|---|---|
source |
RelativeLayout.LayoutParams: The layout params to copy from. |
void addRule (int verb,
int subject)
添加要由RelativeLayout解释的布局规则。
用于引用兄弟(例如 ALIGN_RIGHT )的动词或采用布尔值(例如 CENTER_IN_PARENT )。
如果规则与布局方向有关(例如 START_OF ),则在用绝对规则调用 getRule(int)之前,必须使用 resolveLayoutDirection(int)解析布局方向(例如, LEFT_OF 。
| 参数(Parameters) | |
|---|---|
verb |
int: a layout verb, such as ALIGN_RIGHT |
subject |
int: the ID of another view to use as an anchor, or a boolean value (represented as TRUE for true or 0 for false) |
void addRule (int verb)
添加要由RelativeLayout解释的布局规则。
此方法只应用于不涉及兄弟(例如, ALIGN_RIGHT )的动词或采用布尔值( TRUE为true或0为false)。 要指定带有主题的动词,请使用addRule(int, int) 。
如果规则是相对于布局方向(例如: ALIGN_PARENT_START ),则布局方向必须使用解决 resolveLayoutDirection(int)致电前 getRule(int)绝对的规则(例如: ALIGN_PARENT_LEFT 。
| 参数(Parameters) | |
|---|---|
verb |
int: a layout verb, such as ALIGN_PARENT_LEFT |
String debug (String output)
返回此组布局参数的字符串表示形式。
| 参数(Parameters) | |
|---|---|
output |
String: the String to prepend to the internal representation |
| 返回(Returns) | |
|---|---|
String |
a String with the following format: output + "ViewGroup.LayoutParams={ width=WIDTH, height=HEIGHT }" |
int getRule (int verb)
返回与特定动词关联的布局规则。
| 参数(Parameters) | |
|---|---|
verb |
int: one of the verbs defined by RelativeLayout, such as ALIGN_WITH_PARENT_LEFT |
| 返回(Returns) | |
|---|---|
int |
the id of another view to use as an anchor, a boolean value (represented as TRUE for true or 0 for false), or -1 for verbs that don't refer to another sibling (for example, ALIGN_WITH_PARENT_BOTTOM) |
也可以看看:
int[] getRules ()
检索所有受支持规则的完整列表,其中索引是规则谓词,元素值是指定的值;如果未设置,则检索“false”。 将不会解决相关规则。
| 返回(Returns) | |
|---|---|
int[] |
the supported rules |
也可以看看:
void removeRule (int verb)
删除由RelativeLayout解释的布局规则。
如果规则是相对于布局方向(例如: START_OF , ALIGN_PARENT_START ,等等),则布局方向必须使用解决 resolveLayoutDirection(int)前致电前 getRule(int)具有绝对的规则(例如: LEFT_OF 。
| 参数(Parameters) | |
|---|---|
verb |
int: One of the verbs defined by RelativeLayout, such as ALIGN_WITH_PARENT_LEFT. |
void resolveLayoutDirection (int layoutDirection)
这将由 requestLayout()以解决与布局方向相关的布局参数。
在调用此方法后,以前通过 addRule(int)添加的与布局相关的动词(例如 START_OF )的任何规则只能通过其解析的绝对动词(例如 LEFT_OF )进行访问。
| 参数(Parameters) | |
|---|---|
layoutDirection |
int: the direction of the layout LAYOUT_DIRECTION_LTR LAYOUT_DIRECTION_RTL |