Last Updated:

SeekBar in Android | Example

SeekBar widget on Android

At its core, the widget is an extension of , but with the functionality of dragging the indicator of the current position to the left or right. An example of using this widget in an Android system is volume control or music playback progress in an Android player.SeekBarProgressBar

Similarly, the widget uses two properties: and .ProgressBarSeekBarandroid:maxandroid:progress

To track progress, an interface is used that provides methods for performing handling of various events in:SeekBar.OnSeekBarChangeListenerSeekBar

  • The method is used to notify you of any changes at the . onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)SeekBar
  • The method is used to notify you that the user has touched the progress bar. onStartTrackingTouch(SeekBar SeekBar)
  • The method is used to notify you that the user has finished interacting with the progress bar.onStopTrackingTouch(SeekBar SeekBar)

Example of using SeekBar


Layout with SeekBar widget:

Notice that using the attribute, we specified the maximum value that the widget allows. You can change this indicator in your program, for example, to 10.


Below is a listing of the class:MainActivity

The result of running an application with a widget in Android.SeekBar