diff options
| author | 2011-01-19 17:03:08 -0800 | |
|---|---|---|
| committer | 2011-01-19 17:03:08 -0800 | |
| commit | 2cb866b948c38923b31331a9b2f031eb9d791e6e (patch) | |
| tree | 70758de2cf4a5300e1104f72be5d304ef2c4c5ca | |
| parent | 8bb9131c663b5c4548eed1d9f964d06bccfc4da6 (diff) | |
| parent | fb75738ee28839c67bef4abc15d6c7a407c34f55 (diff) | |
Merge "Never drag scroll views with no children." into honeycomb
| -rw-r--r-- | core/java/android/widget/HorizontalScrollView.java | 8 | ||||
| -rw-r--r-- | core/java/android/widget/ScrollView.java | 8 |
2 files changed, 10 insertions, 6 deletions
diff --git a/core/java/android/widget/HorizontalScrollView.java b/core/java/android/widget/HorizontalScrollView.java index f6b1dbc99b40..db22a0cb1e31 100644 --- a/core/java/android/widget/HorizontalScrollView.java +++ b/core/java/android/widget/HorizontalScrollView.java @@ -511,8 +511,10 @@ public class HorizontalScrollView extends FrameLayout { switch (action & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: { - final float x = ev.getX(); - mIsBeingDragged = true; + mIsBeingDragged = getChildCount() != 0; + if (!mIsBeingDragged) { + return false; + } /* * If being flinged and user touches, stop the fling. isFinished @@ -523,7 +525,7 @@ public class HorizontalScrollView extends FrameLayout { } // Remember where the motion event started - mLastMotionX = x; + mLastMotionX = ev.getX(); mActivePointerId = ev.getPointerId(0); break; } diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java index 8558c70e40de..ce6da72a2c98 100644 --- a/core/java/android/widget/ScrollView.java +++ b/core/java/android/widget/ScrollView.java @@ -521,8 +521,10 @@ public class ScrollView extends FrameLayout { switch (action & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: { - final float y = ev.getY(); - mIsBeingDragged = true; + mIsBeingDragged = getChildCount() != 0; + if (!mIsBeingDragged) { + return false; + } /* * If being flinged and user touches, stop the fling. isFinished @@ -537,7 +539,7 @@ public class ScrollView extends FrameLayout { } // Remember where the motion event started - mLastMotionY = y; + mLastMotionY = ev.getY(); mActivePointerId = ev.getPointerId(0); break; } |