question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Slider] Cannot set stepSize < 1.0

See original GitHub issue

Description: When I set stepSize=0.1 I get next error:

Caused by: java.lang.IllegalArgumentException: The stepSize must be 0, or a factor of the valueFrom-valueTo range
        at com.google.android.material.slider.Slider.validateStepSize(Slider.java:383)
        at com.google.android.material.slider.Slider.processAttributes(Slider.java:360)

Expected behavior: I want to set stepSize=“0.1” for range 0…1

Source code:

<com.google.android.material.slider.Slider
        android:id="@+id/sliderOpacity"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:stepSize="0.1"
        android:valueFrom="0"
        android:valueTo="1" />

Android API version: Android P, Q

Material Library version: 1.2.0-alpha01

Device: AVD, Google Pixel 3

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rootoncommented, Apr 17, 2021

It happens because:

} else if (stepSize > 0.0f && (valueTo - valueFrom) % stepSize != 0.0f) {
      Log.e(TAG, EXCEPTION_ILLEGAL_STEP_SIZE);
      throw new IllegalArgumentException(EXCEPTION_ILLEGAL_STEP_SIZE);

This works fine with integer values. But using float values as in your case in java it is 0.09999999 and not 0.0f.

It is annoying. Why I cant set step size I want, why that limitation?

1reaction
gabrielemariotticommented, Aug 28, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Slider, how to make “step” size change - JQuery - Stack Overflow
I'm having problem with the Slider "step" . In first link the value start in 1.0, the min=0.00010 and the max: 1000000.
Read more >
arbitrary step size with mouse wheel on sliders compared to ...
I'm using the feature (CO 14.4) to adjust sliders using the mouse scroll wheel. I have the issue that the step size looks...
Read more >
Function Flyer and Data Flyer Test Suite - Shodor
The step-size of the slider is controlled in two ways: by the smallest significant digit or by the "set window" dialog box. Display...
Read more >
21. The Scale widget
The purpose of a scale widget is to allow the user to set some int or float value within a specified range. Here...
Read more >
Slider — Kivy 2.1.0 documentation
Slider ¶. Jump to API ⇓. Module: kivy.uix.slider. Added in 1.0.0 ... To create a slider from -100 to 100 starting from 25:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found