@@ -1908,7 +1908,8 @@ private boolean isCandidateSelection(int childIndex, int direction) {
19081908 }
19091909
19101910 /**
1911- * Describes how the child views are horizontally aligned. Defaults to Gravity.LEFT
1911+ * Set the gravity for this grid. Gravity describes how the child views
1912+ * are horizontally aligned. Defaults to Gravity.LEFT
19121913 *
19131914 * @param gravity the gravity to apply to this grid's children
19141915 *
@@ -1921,6 +1922,17 @@ public void setGravity(int gravity) {
19211922 }
19221923 }
19231924
1925+ /**
1926+ * Describes how the child views are horizontally aligned. Defaults to Gravity.LEFT
1927+ *
1928+ * @return the gravity that will be applied to this grid's children
1929+ *
1930+ * @attr ref android.R.styleable#GridView_gravity
1931+ */
1932+ public int getGravity () {
1933+ return mGravity ;
1934+ }
1935+
19241936 /**
19251937 * Set the amount of horizontal (x) spacing to place between each item
19261938 * in the grid.
@@ -1937,6 +1949,44 @@ public void setHorizontalSpacing(int horizontalSpacing) {
19371949 }
19381950 }
19391951
1952+ /**
1953+ * Returns the amount of horizontal spacing currently used between each item in the grid.
1954+ *
1955+ * <p>This is only accurate for the current layout. If {@link #setHorizontalSpacing(int)}
1956+ * has been called but layout is not yet complete, this method may return a stale value.
1957+ * To get the horizontal spacing that was explicitly requested use
1958+ * {@link #getRequestedHorizontalSpacing()}.</p>
1959+ *
1960+ * @return Current horizontal spacing between each item in pixels
1961+ *
1962+ * @see #setHorizontalSpacing(int)
1963+ * @see #getRequestedHorizontalSpacing()
1964+ *
1965+ * @attr ref android.R.styleable#GridView_horizontalSpacing
1966+ */
1967+ public int getHorizontalSpacing () {
1968+ return mHorizontalSpacing ;
1969+ }
1970+
1971+ /**
1972+ * Returns the requested amount of horizontal spacing between each item in the grid.
1973+ *
1974+ * <p>The value returned may have been supplied during inflation as part of a style,
1975+ * the default GridView style, or by a call to {@link #setHorizontalSpacing(int)}.
1976+ * If layout is not yet complete or if GridView calculated a different horizontal spacing
1977+ * from what was requested, this may return a different value from
1978+ * {@link #getHorizontalSpacing()}.</p>
1979+ *
1980+ * @return The currently requested horizontal spacing between items, in pixels
1981+ *
1982+ * @see #setHorizontalSpacing(int)
1983+ * @see #getHorizontalSpacing()
1984+ *
1985+ * @attr ref android.R.styleable#GridView_horizontalSpacing
1986+ */
1987+ public int getRequestedHorizontalSpacing () {
1988+ return mRequestedHorizontalSpacing ;
1989+ }
19401990
19411991 /**
19421992 * Set the amount of vertical (y) spacing to place between each item
@@ -1945,6 +1995,8 @@ public void setHorizontalSpacing(int horizontalSpacing) {
19451995 * @param verticalSpacing The amount of vertical space between items,
19461996 * in pixels.
19471997 *
1998+ * @see #getVerticalSpacing()
1999+ *
19482000 * @attr ref android.R.styleable#GridView_verticalSpacing
19492001 */
19502002 public void setVerticalSpacing (int verticalSpacing ) {
@@ -1954,6 +2006,19 @@ public void setVerticalSpacing(int verticalSpacing) {
19542006 }
19552007 }
19562008
2009+ /**
2010+ * Returns the amount of vertical spacing between each item in the grid.
2011+ *
2012+ * @return The vertical spacing between items in pixels
2013+ *
2014+ * @see #setVerticalSpacing(int)
2015+ *
2016+ * @attr ref android.R.styleable#GridView_verticalSpacing
2017+ */
2018+ public int getVerticalSpacing () {
2019+ return mVerticalSpacing ;
2020+ }
2021+
19572022 /**
19582023 * Control how items are stretched to fill their space.
19592024 *
@@ -1987,6 +2052,39 @@ public void setColumnWidth(int columnWidth) {
19872052 }
19882053 }
19892054
2055+ /**
2056+ * Return the width of a column in the grid.
2057+ *
2058+ * <p>This may not be valid yet if a layout is pending.</p>
2059+ *
2060+ * @return The column width in pixels
2061+ *
2062+ * @see #setColumnWidth(int)
2063+ * @see #getRequestedColumnWidth()
2064+ *
2065+ * @attr ref android.R.styleable#GridView_columnWidth
2066+ */
2067+ public int getColumnWidth () {
2068+ return mColumnWidth ;
2069+ }
2070+
2071+ /**
2072+ * Return the requested width of a column in the grid.
2073+ *
2074+ * <p>This may not be the actual column width used. Use {@link #getColumnWidth()}
2075+ * to retrieve the current real width of a column.</p>
2076+ *
2077+ * @return The requested column width in pixels
2078+ *
2079+ * @see #setColumnWidth(int)
2080+ * @see #getColumnWidth()
2081+ *
2082+ * @attr ref android.R.styleable#GridView_columnWidth
2083+ */
2084+ public int getRequestedColumnWidth () {
2085+ return mRequestedColumnWidth ;
2086+ }
2087+
19902088 /**
19912089 * Set the number of columns in the grid
19922090 *
0 commit comments