summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/Renderers/FormsSeekBar.cs
diff options
context:
space:
mode:
authorRui Marinho <me@ruimarinho.net>2016-08-03 10:07:50 +0100
committerJason Smith <jason.smith@xamarin.com>2016-08-03 02:07:50 -0700
commit671d9466400acc7bd9bc7db45f550b2a4c6cb596 (patch)
tree7a815b402961e62304832400ec430dc7c69f6022 /Xamarin.Forms.Platform.Android/Renderers/FormsSeekBar.cs
parent23614ca8c6cc78cb2b1df91977fd539a9fa159df (diff)
downloadxamarin-forms-671d9466400acc7bd9bc7db45f550b2a4c6cb596.tar.gz
xamarin-forms-671d9466400acc7bd9bc7db45f550b2a4c6cb596.tar.bz2
xamarin-forms-671d9466400acc7bd9bc7db45f550b2a4c6cb596.zip
Fix bugzilla41209 (#216)
* [Android] Add custom FormsSeekbar to handle invalid pressed states send by other views * [Controls] Fix sample , error only occurs with transparent background
Diffstat (limited to 'Xamarin.Forms.Platform.Android/Renderers/FormsSeekBar.cs')
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/FormsSeekBar.cs52
1 files changed, 52 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Android/Renderers/FormsSeekBar.cs b/Xamarin.Forms.Platform.Android/Renderers/FormsSeekBar.cs
new file mode 100644
index 00000000..cb58fbd7
--- /dev/null
+++ b/Xamarin.Forms.Platform.Android/Renderers/FormsSeekBar.cs
@@ -0,0 +1,52 @@
+using System;
+using Android.Widget;
+using Android.Content;
+using Android.Views;
+
+
+namespace Xamarin.Forms.Platform.Android
+{
+ internal class FormsSeekBar : SeekBar
+ {
+ public FormsSeekBar(Context context) : base(context)
+ {
+ //this should work, but it doesn't.
+ DuplicateParentStateEnabled = false;
+ }
+
+ public override bool OnTouchEvent(MotionEvent e)
+ {
+ switch (e.Action)
+ {
+ case MotionEventActions.Down:
+ isTouching = true;
+ break;
+ case MotionEventActions.Up:
+ Pressed = false;
+ break;
+ }
+
+ return base.OnTouchEvent(e);
+ }
+
+ public override bool Pressed
+ {
+ get
+ {
+ return base.Pressed;
+ }
+ set
+ {
+ if (isTouching)
+ {
+ base.Pressed = value;
+ isTouching = value;
+ }
+
+ }
+ }
+
+ bool isTouching = false;
+ }
+}
+