material-components-android
material-components-android copied to clipboard
[Slider] Add new tick visibility modes
- Resolves https://github.com/material-components/material-components-android/issues/1233 (taking into account the wishes of https://github.com/material-components/material-components-android/issues/1233#issuecomment-1201312042)
- Resolves https://github.com/material-components/material-components-android/issues/4237
Highlights
- New tick visibility API:
Slider.getTickVisibilityMode()
,Slider.setTickVisibilityMode(int)
, andapp:tickVisibilityMode
. - New tick visibility modes:
-
visibleAll
- All tick marks will be drawn, even if they are spaced too densely and overlap each other. -
autoLimit
- (Default) All tick marks will be drawn if they are not spaced too densely. Otherwise, the maximum allowed number of tick marks will be drawn. -
autoHide
- All tick marks will be drawn if they are not spaced too densely. Otherwise, the tick marks will not be drawn. -
hidden
- Tick marks will not be drawn at all.
-
-
Slider.setTickVisible(boolean)
is deprecated in favor ofSlider.setTickVisibilityMode(int)
. -
app:tickVisible
is deprecated in favor ofapp:tickVisibilityMode
.
Migration
-
Slider.setTickVisible(true)
->Slider.setTickVisibilityMode(TICK_VISIBILITY_AUTO_LIMIT)
-
Slider.setTickVisible(false)
->Slider.setTickVisibilityMode(TICK_VISIBILITY_HIDDEN)
-
app:tickVisible="true"
->app:tickVisibilityMode="autoLimit"
-
app:tickVisible="false"
->app:tickVisibilityMode="hidden"
No problem. Thanks a lot!
Sorry for the delay. I'm working on this now. : )
I'm running into very weird issues when trying to merge the PR. Somehow the change blocks the argument validation from being done when running unit tests.
I don't really have time to debug it yet. If you can help check that on your end it will also be very helpful.
Checked, fixed, and rebased.
Hey thanks for bumping this!! Sorry I missed your fix during my vacation.
Sending this for internal review now.
No problem. Feel free to review my other open PRs as well.
Hi, during the internal review, people raised that we are not sure what is the use scenario of autoHide
mode?
Do you have an example of that?
Do you have an example of that?
https://github.com/material-components/material-components-android/issues/1233
As for me, I don't like the current default behavior either, because in the "dense" case ticks stop pointing to the position you can drag the slider to.
Dan, can you provide some insights here? I think the latest conversation we had regarding this is we probably need designers' opinion. ^^;
Just in case, I want to make it clear that this PR doesn't change the default behavior of the slider, but only adds two new strategies - autoHide
(reason #1, reason #2) and visibleAll
(I know this approach is not recommended by M3 specs, it's added mostly for symmetry with hidden
).
@drchen any update on this? I talked with our designers and they are not keen on adding this change, especially visibleAll
, maybe removing it would be better.
If you want, I can delete visibleAll
. I already explained why it was added, but I don't need it either and I don't insist on keeping it.
However, the autoHide
should remain, that's what this PR was created for (explanation). Moreover, I believe the new behavior should be made the default one because the current behavior is not just illogical and confusing but directly contradicts the description of stop indicators.
Bump