diff options
author | adrianknight89 <adrianknight89@outlook.com> | 2016-12-19 06:42:16 -0600 |
---|---|---|
committer | Rui Marinho <me@ruimarinho.net> | 2016-12-19 12:42:16 +0000 |
commit | e0165abbcd1329a3dfd353548f5d75eef0c792de (patch) | |
tree | 58c352a50974cb38883e2d221b2766c548af0574 /Xamarin.Forms.Platform.Android | |
parent | 6c8abfdc14138bb803272497b0f97793106acb08 (diff) | |
download | xamarin-forms-e0165abbcd1329a3dfd353548f5d75eef0c792de.tar.gz xamarin-forms-e0165abbcd1329a3dfd353548f5d75eef0c792de.tar.bz2 xamarin-forms-e0165abbcd1329a3dfd353548f5d75eef0c792de.zip |
Slider should show user-set value on initial load (#378)
Diffstat (limited to 'Xamarin.Forms.Platform.Android')
-rw-r--r-- | Xamarin.Forms.Platform.Android/Renderers/SliderRenderer.cs | 30 |
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 |