summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android
diff options
context:
space:
mode:
authoradrianknight89 <adrianknight89@outlook.com>2016-10-31 11:41:46 (GMT)
committerRui Marinho <me@ruimarinho.net>2016-10-31 11:41:46 (GMT)
commitc9edd1a382298d4de622b186d6ef3af69d5f55ac (patch)
tree15ca877359d1a27cd40d740ac1c9b72f035825d5 /Xamarin.Forms.Platform.Android
parentceb09daf2d09c0ad8b2e4029947f66748ad11e9e (diff)
downloadxamarin-forms-c9edd1a382298d4de622b186d6ef3af69d5f55ac.zip
xamarin-forms-c9edd1a382298d4de622b186d6ef3af69d5f55ac.tar.gz
xamarin-forms-c9edd1a382298d4de622b186d6ef3af69d5f55ac.tar.bz2
[Android] Forward ScrollView touch events to custom renderers (#472)
* Forward touch events * remove double cast
Diffstat (limited to 'Xamarin.Forms.Platform.Android')
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/AHorizontalScrollView.cs9
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs8
2 files changed, 16 insertions, 1 deletions
diff --git a/Xamarin.Forms.Platform.Android/Renderers/AHorizontalScrollView.cs b/Xamarin.Forms.Platform.Android/Renderers/AHorizontalScrollView.cs
index 6a64a35..4d192dc 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/AHorizontalScrollView.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/AHorizontalScrollView.cs
@@ -31,6 +31,14 @@ namespace Xamarin.Forms.Platform.Android
public override bool OnTouchEvent(MotionEvent ev)
{
+ // If the touch is caught by the horizontal scrollview, forward it to the parent so custom renderers can be notified of the touch.
+ var verticalScrollViewerRenderer = Parent as ScrollViewRenderer;
+ if (verticalScrollViewerRenderer != null)
+ {
+ verticalScrollViewerRenderer.ShouldSkipOnTouch = true;
+ verticalScrollViewerRenderer.OnTouchEvent(ev);
+ }
+
// The nested ScrollViews will allow us to scroll EITHER vertically OR horizontally in a single gesture.
// This will allow us to also scroll diagonally.
// We'll fall through to the base event so we still get the fling from the ScrollViews.
@@ -49,6 +57,7 @@ namespace Xamarin.Forms.Platform.Android
ScrollBy((int)dX, 0);
}
}
+
return base.OnTouchEvent(ev);
}
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs
index acad08c..2f66d8e 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs
@@ -14,7 +14,7 @@ namespace Xamarin.Forms.Platform.Android
ScrollViewContainer _container;
HorizontalScrollView _hScrollView;
bool _isAttached;
-
+ internal bool ShouldSkipOnTouch;
bool _isBidirectional;
ScrollView _view;
@@ -118,6 +118,12 @@ namespace Xamarin.Forms.Platform.Android
public override bool OnTouchEvent(MotionEvent ev)
{
+ if (ShouldSkipOnTouch)
+ {
+ ShouldSkipOnTouch = false;
+ return false;
+ }
+
// The nested ScrollViews will allow us to scroll EITHER vertically OR horizontally in a single gesture.
// This will allow us to also scroll diagonally.
// We'll fall through to the base event so we still get the fling from the ScrollViews.