Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Is a slider supposed to "slide" in android? I can only click to get a specific value.

$
0
0

So I have a Stacklayout and a slider inside it with a label below showing the value selected like so:

            StackLayout optionLayout = new StackLayout()
            {
                Padding = new Thickness(15, 0),
            };
        Slider slider = new Slider();
                slider.SetBinding(Slider.MaximumProperty, new Binding("MaxRating", BindingMode.OneWay));
                slider.SetBinding(Slider.ValueProperty, new Binding("Rating", BindingMode.TwoWay));
                Label sliderVal = new Label();
                sliderVal.Text = slider.Value.ToString();
                slider.ValueChanged += ((s, a) =>
                {
                    sliderVal.Text = slider.Value.ToString();
                    var newStep = Math.Round(a.NewValue / 1);
                    slider.Value = newStep * 1;
                });
                optionLayout.Children.Add(slider);
                optionLayout.Children.Add(sliderVal);

The value is rounded to the nearest int. but I can only select a value by clicking somewhere on the slider. In this case 1,2,3,4,5. I cannot slide the slider up values. On Windows phone I can slide the slider up the scale to select the next value. But on android I can't. I've tried commenting out ValueChanged and it doesn't make a difference. Was wondering whether this was the correct behavior from my slider?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>