Step size out range in Android Studio (Sliderbar)

I'm trying to give a step size in a sliderbar, and I get an

IllegalStateException error: "The stepSize(200.0) must be 0, or a factor of the valueFrom(100.0)-valueTo(800.0) range".

I'm giving a step size of 200 in a range of 100 to 800. I have to solve the problem using these values. If a solution with sliderbar is not possible, what else could I use?

I tried using seekbar but it won't let me setp in seekbar

Upvotes: 0

Views: 1736

Answers (3)

ojgooo
ojgooo

Reputation: 1

Maybe, you have to make sure range%stepSize=0[in your exp(800-100)%200 = 100] If it is not divisible, it will be counter-intuitive to the user, maybe you should consider whether to modify the product design

Upvotes: 0

sourav
sourav

Reputation: 1

You can change your step size to 100. May be it will help you.

Upvotes: -1

ba1
ba1

Reputation: 49

I can't know exactly what you're doing without a piece of code, but this site gives info on every method related to sliders.

https://developer.android.com/reference/com/google/android/material/slider/Slider#setStepSize(float)

Specifically, here is what it says about setting the step size.

setStepSize

public void setStepSize (float stepSize)

Sets the step size to use to mark the ticks.

Setting this value to 0 will make the slider operate in continuous mode. Setting this value to a number greater than 0 will make the slider operate in discrete mode.

The step size must evenly divide the range described by the valueFrom and valueTo, it must be a factor of the range. If the step size is not a factor of the range, an IllegalStateException will be thrown when this view is laid out.

Upvotes: 1

Related Questions