Android SeekBar - Androhub

Seekbar

Android SeekBar

 

Android SeekBar is the extension of ProgressBar. SeekBar allows the user to change the value using touch event/draggable thumb/left right arrow keys. SeekBar has a thumb that can be slided in order to choose a value between 0 and some maximum that can be set from the developer. The user can increase the value by dragging the thumb right or by pressing the right arrow key. Similarly the user can decrease the value by dragging the thumb left or by pressing the left arrow key.

The seekbar has three states: drag start, changing and drag ended.

Example

In this example I will show you how to implement simple and custom SeekBar.

VIDEO DEMO

Let’s get start by creating a project in Eclipse IDE.

1. Create a new project in Eclipse by navigating to File ⇒ New Android ⇒ Application Project and fill required details. (I kept my main activity name as MainActivity.java).

2.  Create a layout file for MainActivtiy.java under res ⇒ layout folder. I named the layout file as activity_main.xml. In this layout i had taken two SeekBar one for Simple and another for Custom.

3. For custom seekbar we need to create a new xml file for that in drawable folder and set it to seekbar as :

Here custom_progress is xml file created in drawable shown below :

4. Now, come to MainActivity.java and add the following code. In this class we read the tracking on both seekbar and display the seek in textView as text and also work on three states of seekbar as listeners.

5. Now, run the app and you will get the output as shown in video.

Thanks. :)

 

1 Comment

Akshay
Wednesday, June 22nd, 2016

thanks

Post comment

Your email address will not be published. Required fields are marked *