summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2010-03-05 14:48:06 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-03-05 14:48:06 -0800
commit931bf89d327ecf07301231fd86b17deac535feaa (patch)
treee881985dba23957228ef141ce0b012614b670339 /core/java
parent43dcdb2ec5aaad592e16555f9b5ddc037fa71902 (diff)
parent51c5a0c50e8ec5e2cb59bd60f85f3e612eb08931 (diff)
Merge "Added accessors for view overscroll modes"
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/view/View.java47
1 files changed, 44 insertions, 3 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index abbab0ea3498..7a0c4456d11d 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -1516,19 +1516,28 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
/**
* Always allow a user to overscroll this view, provided it is a
* view that can scroll.
+ *
+ * @see #getOverscrollMode()
+ * @see #setOverscrollMode(int)
*/
- private static final int OVERSCROLL_ALWAYS = 0;
+ public static final int OVERSCROLL_ALWAYS = 0;
/**
* Allow a user to overscroll this view only if the content is large
* enough to meaningfully scroll, provided it is a view that can scroll.
+ *
+ * @see #getOverscrollMode()
+ * @see #setOverscrollMode(int)
*/
- private static final int OVERSCROLL_IF_CONTENT_SCROLLS = 1;
+ public static final int OVERSCROLL_IF_CONTENT_SCROLLS = 1;
/**
* Never allow a user to overscroll this view.
+ *
+ * @see #getOverscrollMode()
+ * @see #setOverscrollMode(int)
*/
- private static final int OVERSCROLL_NEVER = 2;
+ public static final int OVERSCROLL_NEVER = 2;
/**
* Controls the overscroll mode for this view.
@@ -8770,6 +8779,38 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
boolean clampedX, boolean clampedY) {
// Intentionally empty.
}
+
+ /**
+ * Returns the overscroll mode for this view. The result will be
+ * one of {@link #OVERSCROLL_ALWAYS} (default), {@link #OVERSCROLL_IF_CONTENT_SCROLLS}
+ * (allow overscrolling only if the view content is larger than the container),
+ * or {@link #OVERSCROLL_NEVER}.
+ *
+ * @return This view's overscroll mode.
+ */
+ public int getOverscrollMode() {
+ return mOverscrollMode;
+ }
+
+ /**
+ * Set the overscroll mode for this view. Valid overscroll modes are
+ * {@link #OVERSCROLL_ALWAYS} (default), {@link #OVERSCROLL_IF_CONTENT_SCROLLS}
+ * (allow overscrolling only if the view content is larger than the container),
+ * or {@link #OVERSCROLL_NEVER}.
+ *
+ * Setting the overscroll mode of a view will have an effect only if the
+ * view is capable of scrolling.
+ *
+ * @param overscrollMode The new overscroll mode for this view.
+ */
+ public void setOverscrollMode(int overscrollMode) {
+ if (overscrollMode != OVERSCROLL_ALWAYS &&
+ overscrollMode != OVERSCROLL_IF_CONTENT_SCROLLS &&
+ overscrollMode != OVERSCROLL_NEVER) {
+ throw new IllegalArgumentException("Invalid overscroll mode " + overscrollMode);
+ }
+ mOverscrollMode = overscrollMode;
+ }
/**
* A MeasureSpec encapsulates the layout requirements passed from parent to child.