Most visited

Recently visited

GridLayout.LayoutParams

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在每个单元组中支持行和列的跨越和任意形式的对齐。 与每个单元组相关的基本参数被收集到它们的垂直和水平分量中,并存储在rowSpeccolumnSpec布局参数中。 Specs是不可变的结构,可以在不同孩子的布局参数之间共享。

行和列规格包含沿每个轴的前导索引和尾随索引,并一起指定划分此单元组的单元格的四个网格索引。

行和列规格的对齐属性一起指定单元组内对齐的两个方面。 也可以使用setGravity(int)方法在其单元组内指定子对齐。

Weight属性也包含在Spec中,并指定由于相关视图而导致的多余空间的比例。

WRAP_CONTENT and MATCH_PARENT

Because the default values of the 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.

Summary

You should not need to use either of the special size values: WRAP_CONTENT or MATCH_PARENT when configuring the children of a GridLayout.

Default values

See GridLayout for a more complete description of the conventions used by GridLayout in the interpretation of the properties of this class.

Summary

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)

为此 rowSpeccolumnSpec构造一个新的LayoutParams实例。

GridLayout.LayoutParams()

使用 GridLayout.LayoutParams定义的默认值构造一个新的LayoutParams。

GridLayout.LayoutParams(ViewGroup.LayoutParams params)

GridLayout.LayoutParams(ViewGroup.MarginLayoutParams params)

GridLayout.LayoutParams(GridLayout.LayoutParams source)

复制构造函数。

GridLayout.LayoutParams(Context context, AttributeSet attrs)

未在属性集中定义的值采用 GridLayout.LayoutParams定义的默认值。

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

Fields

columnSpec

GridLayout.Spec columnSpec

定义这些布局参数描述的单元组的水平特性的规范。 如果在测量或布局操作完成后对此字段进行分配,则必须调用setLayoutParams(ViewGroup.LayoutParams)以通知GridLayout该更改。 GridLayout通常能够检测代码未能遵守这一规则,发出警告并采取措施补偿遗漏。 该设施以尽力而为的方式实施,不应依赖于生产代码 - 因此最好包括上述呼吁,以便在实际情况下立即删除警告。

rowSpec

GridLayout.Spec rowSpec

定义这些布局参数所描述的单元组的垂直特性的规范。 如果在测量或布局操作完成后对此字段进行分配,则必须致电setLayoutParams(ViewGroup.LayoutParams)以通知GridLayout该更改。 GridLayout通常能够检测代码未能遵守这一规则,发出警告并采取措施补偿遗漏。 该设施以尽力而为的方式实施,不应依赖于生产代码 - 因此最好包括上述呼吁,以便在实际情况下立即删除警告。

Public constructors

GridLayout.LayoutParams

GridLayout.LayoutParams (GridLayout.Spec rowSpec, 
                GridLayout.Spec columnSpec)

为此rowSpeccolumnSpec构造一个新的LayoutParams实例。 所有其他字段都使用GridLayout.LayoutParams定义的默认值进行初始化。

Parameters
rowSpec GridLayout.Spec: the rowSpec
columnSpec GridLayout.Spec: the columnSpec

GridLayout.LayoutParams

GridLayout.LayoutParams ()

使用 GridLayout.LayoutParams定义的默认值构造一个新的LayoutParams。

GridLayout.LayoutParams

GridLayout.LayoutParams (ViewGroup.LayoutParams params)

Parameters
params ViewGroup.LayoutParams

GridLayout.LayoutParams

GridLayout.LayoutParams (ViewGroup.MarginLayoutParams params)

Parameters
params ViewGroup.MarginLayoutParams

GridLayout.LayoutParams

GridLayout.LayoutParams (GridLayout.LayoutParams source)

复制构造函数。 克隆源的宽度,高度,边距值,行规格和列规格。

Parameters
source GridLayout.LayoutParams: The layout params to copy from.

GridLayout.LayoutParams

GridLayout.LayoutParams (Context context, 
                AttributeSet attrs)

未在属性集中定义的值采用 GridLayout.LayoutParams定义的默认值。

Parameters
context Context
attrs AttributeSet

Public methods

equals

boolean equals (Object o)

指示其他某个对象是否“等于”这一个。

equals方法在非空对象引用上实现等价关系:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values 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.
  • For any non-null reference value x, x.equals(null) should return false.

Objectequals方法实现了对象上最可能的等价关系; 也就是说,对于任何非空参考值xy ,当且仅当xy引用同一对象( 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.

hashCode

int hashCode ()

返回对象的哈希码值。 为了散列表的好处而支持此方法,例如由HashMap提供的HashMap

hashCode的总合同是:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the 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.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the 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.

setGravity

void setGravity (int gravity)

介绍子视图的定位方式。 默认为LEFT | BASELINE Gravity

Parameters
gravity int: the new gravity value

Protected methods

setBaseAttributes

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

Hooray!