summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/SliderRenderer.cs30
1 files changed, 18 insertions, 12 deletions
diff --git a/Xamarin.Forms.Platform.Android/Renderers/SliderRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/SliderRenderer.cs
index 5df5bf31..2f94b411 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/SliderRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/SliderRenderer.cs
@@ -7,8 +7,8 @@ namespace Xamarin.Forms.Platform.Android
{
public class SliderRenderer : ViewRenderer<Slider, SeekBar>, SeekBar.IOnSeekBarChangeListener
{
- double _max;
- double _min;
+ double _max, _min;
+ bool _progressChangedOnce;
public SliderRenderer()
{
@@ -23,6 +23,12 @@ namespace Xamarin.Forms.Platform.Android
void SeekBar.IOnSeekBarChangeListener.OnProgressChanged(SeekBar seekBar, int progress, bool fromUser)
{
+ if (!_progressChangedOnce)
+ {
+ _progressChangedOnce = true;
+ return;
+ }
+
((IElementController)Element).SetValueFromRenderer(Slider.ValueProperty, Value);
}
@@ -84,20 +90,20 @@ namespace Xamarin.Forms.Platform.Android
base.OnLayout(changed, l, t, r, b);
BuildVersionCodes androidVersion = Build.VERSION.SdkInt;
- if (androidVersion >= BuildVersionCodes.JellyBean)
- {
- // Thumb only supported JellyBean and higher
+ if (androidVersion < BuildVersionCodes.JellyBean)
+ return;
- if (Control == null)
- return;
+ // Thumb only supported JellyBean and higher
- SeekBar seekbar = Control;
+ if (Control == null)
+ return;
- Drawable thumb = seekbar.Thumb;
- int thumbTop = seekbar.Height / 2 - thumb.IntrinsicHeight / 2;
+ SeekBar seekbar = Control;
- thumb.SetBounds(thumb.Bounds.Left, thumbTop, thumb.Bounds.Left + thumb.IntrinsicWidth, thumbTop + thumb.IntrinsicHeight);
- }
+ Drawable thumb = seekbar.Thumb;
+ int thumbTop = seekbar.Height / 2 - thumb.IntrinsicHeight / 2;
+
+ thumb.SetBounds(thumb.Bounds.Left, thumbTop, thumb.Bounds.Left + thumb.IntrinsicWidth, thumbTop + thumb.IntrinsicHeight);
}
}
} \ No newline at end of file