Merge "Added accessors for view overscroll modes"
diff --git a/api/current.xml b/api/current.xml
index 7f0fb94..fd8a180 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -175466,6 +175466,17 @@
visibility="public"
>
</method>
+<method name="getOverscrollMode"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
<method name="getPaddingBottom"
return="int"
abstract="false"
@@ -177631,6 +177642,19 @@
<parameter name="l" type="android.view.View.OnTouchListener">
</parameter>
</method>
+<method name="setOverscrollMode"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="overscrollMode" type="int">
+</parameter>
+</method>
<method name="setPadding"
return="void"
abstract="false"
@@ -178253,6 +178277,39 @@
visibility="public"
>
</field>
+<field name="OVERSCROLL_ALWAYS"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="OVERSCROLL_IF_CONTENT_SCROLLS"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="OVERSCROLL_NEVER"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
<field name="PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET"
type="int[]"
transient="false"
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index abbab0e..7a0c445 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -1516,19 +1516,28 @@
/**
* 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 @@
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.