Android 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. :)

Download Source Code – >

COMMENTS (1)
Reply

thanks

Leave a Comment

Comment (required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Name (required)
Email (required)