summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2011-06-13 18:45:40 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-06-13 18:45:40 -0700
commit2714abff5cc50b1487c0979c99cc685f5ea113b1 (patch)
tree0fd013a0cb08007cb461d62479e58b1e8aac8586 /core/java/android
parent14f58ffceb917151c9940786320415331f340185 (diff)
parent6915944fc722fd8a7d4f26a02faaee51afdfc5c1 (diff)
downloadframeworks_base-2714abff5cc50b1487c0979c99cc685f5ea113b1.zip
frameworks_base-2714abff5cc50b1487c0979c99cc685f5ea113b1.tar.gz
frameworks_base-2714abff5cc50b1487c0979c99cc685f5ea113b1.tar.bz2
Merge "Expose api on View to determine if the view can be scrolled."
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/view/View.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index ee18722..071905c 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -8457,6 +8457,40 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit
}
/**
+ * Check if this view can be scrolled horizontally in a certain direction.
+ *
+ * @param direction Negative to check scrolling left, positive to check scrolling right.
+ * @return true if this view can be scrolled in the specified direction, false otherwise.
+ */
+ public boolean canScrollHorizontally(int direction) {
+ final int offset = computeHorizontalScrollOffset();
+ final int range = computeHorizontalScrollRange() - computeHorizontalScrollExtent();
+ if (range == 0) return false;
+ if (direction < 0) {
+ return offset > 0;
+ } else {
+ return offset < range - 1;
+ }
+ }
+
+ /**
+ * Check if this view can be scrolled vertically in a certain direction.
+ *
+ * @param direction Negative to check scrolling up, positive to check scrolling down.
+ * @return true if this view can be scrolled in the specified direction, false otherwise.
+ */
+ public boolean canScrollVertically(int direction) {
+ final int offset = computeVerticalScrollOffset();
+ final int range = computeVerticalScrollRange() - computeVerticalScrollExtent();
+ if (range == 0) return false;
+ if (direction < 0) {
+ return offset > 0;
+ } else {
+ return offset < range - 1;
+ }
+ }
+
+ /**
* <p>Request the drawing of the horizontal and the vertical scrollbar. The
* scrollbars are painted only if they have been awakened first.</p>
*