Modify activity_main.xml file
XML
<? xml version = "1.0" encoding = "utf-8" ?> < RelativeLayout xmlns:android = "http://schemas.android.com/apk/res/android" android:layout_width = "match_parent" android:layout_height = "match_parent" android:gravity = "center" android:orientation = "vertical" > < SeekBar android:id = "@+id/seekBar" style = "@style/Widget.AppCompat.SeekBar.Discrete" android:layout_width = "match_parent" android:layout_height = "wrap_content" android:min = "1" android:max = "10" android:progress = "7" /> </ RelativeLayout > |
Note:
style=”@style/Widget.AppCompat.SeekBar.Discrete”
This style is used to display the seekBar to make it work for discrete values.
Discrete SeekBar in Kotlin
In Android Discrete SeekBar is just an advancement of progressBar just like the SeekBar, the only difference in SeekBar and discrete SeekBar being that in discrete SeekBar, we can only set the value only to discrete values like 1, 2, 3, and so on.
In this article, we will be discussing how to create a SeekBar in Kotlin.
Contact Us