summaryrefslogtreecommitdiff
path: root/core/java/android/widget/GridView.java
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2012-03-21 14:51:41 -0700
committerAdam Powell <adamp@google.com>2012-03-21 15:35:39 -0700
commit0b7413d5d6239b7bc43816bea5187b323a633b11 (patch)
tree9abeaff9af48b451d9124979b6871485ddeabca6 /core/java/android/widget/GridView.java
parent63b9e973e53476db36eb9cb9f14f0e5c0805d0bd (diff)
GridView attribute updates
Bring GridView's API in sync with its supported style attributes. Bug 6103758 Change-Id: Ib2c4d4d48061d23a7d886364965f0cb50c239e5d
Diffstat (limited to 'core/java/android/widget/GridView.java')
-rw-r--r--core/java/android/widget/GridView.java100
1 files changed, 99 insertions, 1 deletions
diff --git a/core/java/android/widget/GridView.java b/core/java/android/widget/GridView.java
index 739bcce1261d..0f1dab58ea7a 100644
--- a/core/java/android/widget/GridView.java
+++ b/core/java/android/widget/GridView.java
@@ -1908,7 +1908,8 @@ public class GridView extends AbsListView {
}
/**
- * Describes how the child views are horizontally aligned. Defaults to Gravity.LEFT
+ * Set the gravity for this grid. Gravity describes how the child views
+ * are horizontally aligned. Defaults to Gravity.LEFT
*
* @param gravity the gravity to apply to this grid's children
*
@@ -1922,6 +1923,17 @@ public class GridView extends AbsListView {
}
/**
+ * Describes how the child views are horizontally aligned. Defaults to Gravity.LEFT
+ *
+ * @return the gravity that will be applied to this grid's children
+ *
+ * @attr ref android.R.styleable#GridView_gravity
+ */
+ public int getGravity() {
+ return mGravity;
+ }
+
+ /**
* Set the amount of horizontal (x) spacing to place between each item
* in the grid.
*
@@ -1937,6 +1949,44 @@ public class GridView extends AbsListView {
}
}
+ /**
+ * Returns the amount of horizontal spacing currently used between each item in the grid.
+ *
+ * <p>This is only accurate for the current layout. If {@link #setHorizontalSpacing(int)}
+ * has been called but layout is not yet complete, this method may return a stale value.
+ * To get the horizontal spacing that was explicitly requested use
+ * {@link #getRequestedHorizontalSpacing()}.</p>
+ *
+ * @return Current horizontal spacing between each item in pixels
+ *
+ * @see #setHorizontalSpacing(int)
+ * @see #getRequestedHorizontalSpacing()
+ *
+ * @attr ref android.R.styleable#GridView_horizontalSpacing
+ */
+ public int getHorizontalSpacing() {
+ return mHorizontalSpacing;
+ }
+
+ /**
+ * Returns the requested amount of horizontal spacing between each item in the grid.
+ *
+ * <p>The value returned may have been supplied during inflation as part of a style,
+ * the default GridView style, or by a call to {@link #setHorizontalSpacing(int)}.
+ * If layout is not yet complete or if GridView calculated a different horizontal spacing
+ * from what was requested, this may return a different value from
+ * {@link #getHorizontalSpacing()}.</p>
+ *
+ * @return The currently requested horizontal spacing between items, in pixels
+ *
+ * @see #setHorizontalSpacing(int)
+ * @see #getHorizontalSpacing()
+ *
+ * @attr ref android.R.styleable#GridView_horizontalSpacing
+ */
+ public int getRequestedHorizontalSpacing() {
+ return mRequestedHorizontalSpacing;
+ }
/**
* Set the amount of vertical (y) spacing to place between each item
@@ -1945,6 +1995,8 @@ public class GridView extends AbsListView {
* @param verticalSpacing The amount of vertical space between items,
* in pixels.
*
+ * @see #getVerticalSpacing()
+ *
* @attr ref android.R.styleable#GridView_verticalSpacing
*/
public void setVerticalSpacing(int verticalSpacing) {
@@ -1955,6 +2007,19 @@ public class GridView extends AbsListView {
}
/**
+ * Returns the amount of vertical spacing between each item in the grid.
+ *
+ * @return The vertical spacing between items in pixels
+ *
+ * @see #setVerticalSpacing(int)
+ *
+ * @attr ref android.R.styleable#GridView_verticalSpacing
+ */
+ public int getVerticalSpacing() {
+ return mVerticalSpacing;
+ }
+
+ /**
* Control how items are stretched to fill their space.
*
* @param stretchMode Either {@link #NO_STRETCH},
@@ -1988,6 +2053,39 @@ public class GridView extends AbsListView {
}
/**
+ * Return the width of a column in the grid.
+ *
+ * <p>This may not be valid yet if a layout is pending.</p>
+ *
+ * @return The column width in pixels
+ *
+ * @see #setColumnWidth(int)
+ * @see #getRequestedColumnWidth()
+ *
+ * @attr ref android.R.styleable#GridView_columnWidth
+ */
+ public int getColumnWidth() {
+ return mColumnWidth;
+ }
+
+ /**
+ * Return the requested width of a column in the grid.
+ *
+ * <p>This may not be the actual column width used. Use {@link #getColumnWidth()}
+ * to retrieve the current real width of a column.</p>
+ *
+ * @return The requested column width in pixels
+ *
+ * @see #setColumnWidth(int)
+ * @see #getColumnWidth()
+ *
+ * @attr ref android.R.styleable#GridView_columnWidth
+ */
+ public int getRequestedColumnWidth() {
+ return mRequestedColumnWidth;
+ }
+
+ /**
* Set the number of columns in the grid
*
* @param numColumns The desired number of columns.