Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

manabu-nakamura
Copy link
Contributor

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

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>

Screenshot_20241022_151553
Screenshot_20241022_151646
(Compose)
Screenshot_20241020_194418

@drchen
Copy link
Contributor

drchen commented Aug 16, 2024

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

@akhbulatov
Copy link

Any progress?

@manabu-nakamura
Copy link
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 doesn't present both the inactive track and the inactive track stop indicator.
    Screenshot_20241024_112831
  • When android:valueFrom == android:valueTo, the slider presents the inactive track but doesn't present the inactive track stop indicator.
    Screenshot_20241024_112709
  • (Compose) When valueRange = 0f..0f, the slider presents both the inactive track and the inactive track stop indicator.
    Screenshot_20241024_113004

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