ANDROID 【GRIDVIEW】 DETAILED ANNOTATION

TRANSLATE FROM THE WEBSITE OF ANDROID DEVELOPERS BY MYSELF.

ANDROID 【GRIDVIEW】 DETAILED ANNOTATION_第1张图片

XML Attributes
Attribute Name                          Related Method                    Description
android:columnWidth setColumnWidth(int) 为每列指定固定列宽。
android:gravity setGravity(int) 为每个单元格指定对齐方式,
当有多个,可以用 “ | ” 隔开。
android:horizontalSpacing setHorizontalSpacing(int) 定义横向间距(列与列之间)的默认值。
android:numColumns setNumColumns(int) 定义显示的列的个数。
android:stretchMode setStretchMode(int) 定义列怎样延伸来填充可用空间,
如果有可有空间的话。
android:verticalSpacing setVerticalSpacing(int) 定义竖向间距(行与行之间)的默认值。
一、AT FIRST, LET US VIEW ANDROID:STRETCHMODE:

1、1  android:stretchMode

定义列怎样延伸来填充可用空间距,如果有可有空间的话。

该属性值必须为一下常量之一:

Constant Value Description
none 0 不拉伸。
spacingWidth 1 列间距会被拉伸。忽略android:horizontalSpacing属性值。
列宽由android:columnWidth属性值决定。
其中,左边列和右边列会分别贴近左右两边。
columnWidth 2 每一列会被等距拉伸。忽视android:columnWidth属性值。
此时,可不设置android:columnWidth属性值,
其他3种情况必须指定,否则不显示item。

列宽会自适应。
spacingWidthUniform 3 列间距会被均等拉伸。忽略android:horizontalSpacing属性值。
列宽由android:columnWidth属性值决定。
其中,左边列和右边列的左右两边都会有等间距。

This corresponds to the global attribute resource symbol stretchMode.

Related Methods
  • setStretchMode(int)

1、2  ANDROID:STRETCHMODE EFFECT PICTURE AS FOLLOWS:(android:columnWidth="30dp")

android:stretchMode="none";

ANDROID 【GRIDVIEW】 DETAILED ANNOTATION_第2张图片

android:stretchMode="columnWidth";

ANDROID 【GRIDVIEW】 DETAILED ANNOTATION_第3张图片

android:stretchMode="spacingWidth";

ANDROID 【GRIDVIEW】 DETAILED ANNOTATION_第4张图片

android:stretchMode="spacingWidthUniform";

ANDROID 【GRIDVIEW】 DETAILED ANNOTATION_第5张图片

你可能感兴趣的:(ANDROID 【GRIDVIEW】 DETAILED ANNOTATION)