public static class GridLayout.LayoutParams
extends ViewGroup.MarginLayoutParams
java.lang.Object | |||
↳ | android.view.ViewGroup.LayoutParams | ||
↳ | android.view.ViewGroup.MarginLayoutParams | ||
↳ | android.support.v7.widget.GridLayout.LayoutParams |
布局信息与GridLayout的每个子节点相关联。
GridLayout在每个单元组中支持行和列的跨越和任意形式的对齐。 与每个单元组相关的基本参数被收集到它们的垂直和水平分量中,并存储在rowSpec
和columnSpec
布局参数中。 Specs
是不可变的结构,可以在不同孩子的布局参数之间共享。
行和列规格包含沿每个轴的前导索引和尾随索引,并一起指定划分此单元组的单元格的四个网格索引。
行和列规格的对齐属性一起指定单元组内对齐的两个方面。 也可以使用setGravity(int)
方法在其单元组内指定子对齐。
Weight属性也包含在Spec中,并指定由于相关视图而导致的多余空间的比例。
width
and
height
properties are both
WRAP_CONTENT
, this value never needs to be explicitly declared in the layout parameters of GridLayout's children. In addition, GridLayout does not distinguish the special size value
MATCH_PARENT
from
WRAP_CONTENT
. A component's ability to expand to the size of the parent is instead controlled by the principle of
flexibility, as discussed in
GridLayout
.
WRAP_CONTENT
or
MATCH_PARENT
when configuring the children of a GridLayout.
width
= WRAP_CONTENT
height
= WRAP_CONTENT
topMargin
= 0 when useDefaultMargins
is false
; otherwise UNDEFINED
, to indicate that a default value should be computed on demand. leftMargin
= 0 when useDefaultMargins
is false
; otherwise UNDEFINED
, to indicate that a default value should be computed on demand. bottomMargin
= 0 when useDefaultMargins
is false
; otherwise UNDEFINED
, to indicate that a default value should be computed on demand. rightMargin
= 0 when useDefaultMargins
is false
; otherwise UNDEFINED
, to indicate that a default value should be computed on demand. rowSpec
.row
= UNDEFINED
rowSpec
.rowSpan
= 1 rowSpec
.alignment
= BASELINE
rowSpec
.weight
= 0 columnSpec
.column
= UNDEFINED
columnSpec
.columnSpan
= 1 columnSpec
.alignment
= START
columnSpec
.weight
= 0 GridLayout
for a more complete description of the conventions used by GridLayout in the interpretation of the properties of this class.
Inherited XML attributes |
|
---|---|
From class android.view.ViewGroup.MarginLayoutParams
|
|
From class android.view.ViewGroup.LayoutParams
|
Inherited constants |
---|
From class android.view.ViewGroup.LayoutParams
|
Fields |
|
---|---|
public GridLayout.Spec |
columnSpec 定义这些布局参数描述的单元组的水平特性的规范。 |
public GridLayout.Spec |
rowSpec 定义这些布局参数所描述的单元组的垂直特性的规范。 |
Inherited fields |
---|
From class android.view.ViewGroup.MarginLayoutParams
|
From class android.view.ViewGroup.LayoutParams
|
Public constructors |
|
---|---|
GridLayout.LayoutParams(GridLayout.Spec rowSpec, GridLayout.Spec columnSpec) 为此 |
|
GridLayout.LayoutParams() 使用 |
|
GridLayout.LayoutParams(ViewGroup.LayoutParams params) |
|
GridLayout.LayoutParams(ViewGroup.MarginLayoutParams params) |
|
GridLayout.LayoutParams(GridLayout.LayoutParams source) 复制构造函数。 |
|
GridLayout.LayoutParams(Context context, AttributeSet attrs) 未在属性集中定义的值采用 |
Public methods |
|
---|---|
boolean |
equals(Object o) 指示其他某个对象是否“等于”这一个。 |
int |
hashCode() 返回对象的哈希码值。 |
void |
setGravity(int gravity) 介绍子视图的定位方式。 |
Protected methods |
|
---|---|
void |
setBaseAttributes(TypedArray attributes, int widthAttr, int heightAttr) 从提供的属性中提取布局参数。 |
Inherited methods |
|
---|---|
From class android.view.ViewGroup.MarginLayoutParams
|
|
From class android.view.ViewGroup.LayoutParams
|
|
From class java.lang.Object
|
GridLayout.Spec columnSpec
定义这些布局参数描述的单元组的水平特性的规范。 如果在测量或布局操作完成后对此字段进行分配,则必须调用setLayoutParams(ViewGroup.LayoutParams)
以通知GridLayout该更改。 GridLayout通常能够检测代码未能遵守这一规则,发出警告并采取措施补偿遗漏。 该设施以尽力而为的方式实施,不应依赖于生产代码 - 因此最好包括上述呼吁,以便在实际情况下立即删除警告。
GridLayout.Spec rowSpec
定义这些布局参数所描述的单元组的垂直特性的规范。 如果在测量或布局操作完成后对此字段进行分配,则必须致电setLayoutParams(ViewGroup.LayoutParams)
以通知GridLayout该更改。 GridLayout通常能够检测代码未能遵守这一规则,发出警告并采取措施补偿遗漏。 该设施以尽力而为的方式实施,不应依赖于生产代码 - 因此最好包括上述呼吁,以便在实际情况下立即删除警告。
GridLayout.LayoutParams (GridLayout.Spec rowSpec, GridLayout.Spec columnSpec)
为此rowSpec
和columnSpec
构造一个新的LayoutParams实例。 所有其他字段都使用GridLayout.LayoutParams
定义的默认值进行初始化。
Parameters | |
---|---|
rowSpec |
GridLayout.Spec : the rowSpec |
columnSpec |
GridLayout.Spec : the columnSpec |
GridLayout.LayoutParams ()
使用 GridLayout.LayoutParams
定义的默认值构造一个新的LayoutParams。
GridLayout.LayoutParams (ViewGroup.LayoutParams params)
Parameters | |
---|---|
params |
ViewGroup.LayoutParams
|
GridLayout.LayoutParams (ViewGroup.MarginLayoutParams params)
Parameters | |
---|---|
params |
ViewGroup.MarginLayoutParams
|
GridLayout.LayoutParams (GridLayout.LayoutParams source)
复制构造函数。 克隆源的宽度,高度,边距值,行规格和列规格。
Parameters | |
---|---|
source |
GridLayout.LayoutParams : The layout params to copy from. |
GridLayout.LayoutParams (Context context, AttributeSet attrs)
未在属性集中定义的值采用 GridLayout.LayoutParams
定义的默认值。
Parameters | |
---|---|
context |
Context
|
attrs |
AttributeSet
|
boolean equals (Object o)
指示其他某个对象是否“等于”这一个。
equals
方法在非空对象引用上实现等价关系:
x
, x.equals(x)
should return true
. x
and y
, x.equals(y)
should return true
if and only if y.equals(x)
returns true
. x
, y
, and z
, if x.equals(y)
returns true
and y.equals(z)
returns true
, then x.equals(z)
should return true
. x
and y
, multiple invocations of x.equals(y)
consistently return true
or consistently return false
, provided no information used in equals
comparisons on the objects is modified. x
, x.equals(null)
should return false
. 类Object
的equals
方法实现了对象上最可能的等价关系; 也就是说,对于任何非空参考值x
和y
,当且仅当x
和y
引用同一对象( x == y
的值为true
)时,此方法返回true
。
请注意,无论何时覆盖此方法,通常都需要覆盖 hashCode
方法,以维护 hashCode
方法的一般合同,该方法声明等同对象必须具有相同的哈希码。
Parameters | |
---|---|
o |
Object : the reference object with which to compare. |
Returns | |
---|---|
boolean |
true if this object is the same as the obj argument; false otherwise. |
int hashCode ()
返回对象的哈希码值。 为了散列表的好处而支持此方法,例如由HashMap
提供的HashMap
。
hashCode
的总合同是:
hashCode
method must consistently return the same integer, provided no information used in equals
comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. equals(Object)
method, then calling the hashCode
method on each of the two objects must produce the same integer result. equals(java.lang.Object)
method, then calling the hashCode
method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables. 尽可能合理实用,类Object
定义的hashCode方法确实为不同的对象返回不同的整数。 (这通常通过将对象的内部地址转换为整数来实现,但Java TM编程语言不需要此实现技术。)
Returns | |
---|---|
int |
a hash code value for this object. |
void setGravity (int gravity)
介绍子视图的定位方式。 默认为LEFT | BASELINE
。 见Gravity
。
Parameters | |
---|---|
gravity |
int : the new gravity value |
void setBaseAttributes (TypedArray attributes, int widthAttr, int heightAttr)
从提供的属性中提取布局参数。
Parameters | |
---|---|
attributes |
TypedArray : the style attributes to extract the parameters from |
widthAttr |
int : the identifier of the width attribute |
heightAttr |
int : the identifier of the height attribute |