I am new to Android and i am learning SeekBars. in Google material design site i found Sliders from (com.google.android.material.slider.Slider) package instead of seekbars. I wonder what the difference is between Slider and SeekBar, which should I use and which is better? What is the purpose of implementing these two? I search a lot and There is no useful content on the internet
The following may not be entirely accurate to the last detail, but it illustrates some of the history well enough:
Slider
is just the MDC version of SeekBar
- named a little differently and with a lot more functionality.
First, there was only SeekBar
- the original framework UI component bundled with Android.
Then, AndroidX
libraries, previously called Support Libraries
, were created for backporting new UI components and bugfixes to older phones which OEMs refused to update anymore. The AndroidX AppCompat
subproject swaps out all your framework components for the "fixed" versions whenever you use AppCompatActivity
. SeekBar
-> AppCompatSeekBar
, TextView
-> AppCompatTextView
...
The old Support Libraries
also had a package named design
which contained some of the then-new Material 1.0
components (CardView
and whatnot) which didn't have a framework counterpart. That's the reason why there is no AppCompatCardView
- because there is no framework CardView
, so there is nothing to "fix" with AppCompat.
If I recall correctly, the design
package of the Support Libraries
later became the starting point for the Android implementation of Material Components
when Material 2.0
was unveiled. Material Design has its own version of SeekBar
which is called Slider
and it can do everything the old Android SeekBar
can plus a lot more.
As for which one to use? (Neither is "better", that kind of thinking is inapplicable)
Slider
's advanced capabilities, use Slider.SeekBar
instead of pulling the MDC library just for that.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With