Skip to content

[Slider][RangeSlider] valueFrom and valueTo can have the same value - #4257

Open
manabu-nakamura wants to merge 12 commits into
material-components:masterfrom
manabu-nakamura:slider4
Open

manabu-nakamura wants to merge 12 commits into
material-components:masterfrom
manabu-nakamura:slider4

Conversation

@manabu-nakamura

@manabu-nakamura manabu-nakamura commented Aug 12, 2024 •

Copy link
Copy Markdown
Contributor

closes #2787

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <com.google.android.material.slider.Slider
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:valueFrom="0"
        android:valueTo="2"
        app:labelBehavior="visible" />
    <com.google.android.material.slider.Slider
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:valueFrom="0"
        android:valueTo="2"
        android:stepSize="1"
        app:labelBehavior="visible" />
    <com.google.android.material.slider.RangeSlider
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:valueFrom="0"
        android:valueTo="2"
        app:values="@array/initial_slider_values"
        app:labelBehavior="visible" />
    <com.google.android.material.slider.Slider
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:valueFrom="0"
        android:valueTo="0"
        app:labelBehavior="visible" />
    <com.google.android.material.slider.Slider
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:valueFrom="0"
        android:valueTo="0"
        android:stepSize="1"
        app:labelBehavior="visible" />
    <com.google.android.material.slider.RangeSlider
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:valueFrom="0"
        android:valueTo="0"
        app:values="@array/initial_slider_values"
        app:labelBehavior="visible" />
</LinearLayout>
<resources>
    <array name="initial_slider_values">
        <item>0</item>
        <item>0</item>
    </array>
</resources>

(LTR)
Screenshot_20241022_151553
(RTL)
Screenshot_20241022_151646
(Jetpack Compose)
Screenshot_20241020_194418

@drchen

drchen commented Aug 16, 2024

Copy link
Copy Markdown
Contributor

I'm reluctant about the change as it may break a bunch of logic. Dan, can take a look?

@manabu-nakamura

manabu-nakamura commented Oct 24, 2024 •

Copy link
Copy Markdown
Contributor Author

Discussion
https://m3.material.io/components/sliders/specs
https://m3.material.io/components/sliders/overview#f816e17e-2386-4edc-b7d1-10bffe48d0a9:

Sliders should present the full range of choices that are available

  • When android:valueFrom == android:valueTo, the slider presents the inactive track but doesn't present the inactive track stop indicator.
    Screenshot_20241024_112709
  • (Jetpack Compose) When valueRange = 0f..0f, the slider presents both the inactive track and the inactive track stop indicator.
    Screenshot_20241024_113004

@paulfthomas paulfthomas self-assigned this Dec 5, 2024
@manabu-nakamura

Copy link
Copy Markdown
Contributor Author

867fd01

@dsn5ft dsn5ft removed their assignment May 12, 2026
@paulfthomas paulfthomas removed their assignment Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Slider] java.lang.IllegalStateException: valueFrom(2.0) must be smaller than valueTo(2.0)

4 participants