diff options
author | E.Z. Hart <hartez@users.noreply.github.com> | 2017-07-24 16:57:31 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-24 16:57:31 -0400 |
commit | 7303d60ab69a0c2b3c3e54e177efa0d54a7a08de (patch) | |
tree | 89424276785f6b39e4c365eabcdee4728ded957e /Xamarin.Forms.Platform.Android | |
parent | b19c401312227e9661fef63ab1c012614cb95fe1 (diff) | |
download | xamarin-forms-7303d60ab69a0c2b3c3e54e177efa0d54a7a08de.tar.gz xamarin-forms-7303d60ab69a0c2b3c3e54e177efa0d54a7a08de.tar.bz2 xamarin-forms-7303d60ab69a0c2b3c3e54e177efa0d54a7a08de.zip |
Disallow scrolling in ScrollView when IsEnabled set to False (#1049)
* Repro and fix for iOS
* Automated tests
* Fix for Android
* Update issue number
* Alternate version of test which I hope will work on iOS 8
* trying yet another variation of the test which will hopefully work on iOS 8
Diffstat (limited to 'Xamarin.Forms.Platform.Android')
-rw-r--r-- | Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs index 61a721c7..f3413b8c 100644 --- a/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs +++ b/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs @@ -20,6 +20,7 @@ namespace Xamarin.Forms.Platform.Android bool _isBidirectional; ScrollView _view; int _previousBottom; + bool _isEnabled; public ScrollViewRenderer() : base(Forms.Context) { @@ -79,8 +80,8 @@ namespace Xamarin.Forms.Platform.Android LoadContent(); UpdateBackgroundColor(); - UpdateOrientation(); + UpdateIsEnabled(); element.SendViewInitialized(this); @@ -129,6 +130,9 @@ namespace Xamarin.Forms.Platform.Android public override bool OnTouchEvent(MotionEvent ev) { + if (!_isEnabled) + return false; + if (ShouldSkipOnTouch) { ShouldSkipOnTouch = false; @@ -263,6 +267,18 @@ namespace Xamarin.Forms.Platform.Android UpdateBackgroundColor(); else if (e.PropertyName == ScrollView.OrientationProperty.PropertyName) UpdateOrientation(); + else if (e.PropertyName == VisualElement.IsEnabledProperty.PropertyName) + UpdateIsEnabled(); + } + + void UpdateIsEnabled() + { + if (Element == null) + { + return; + } + + _isEnabled = Element.IsEnabled; } void LoadContent() |