From the SDK can be learned that it is the expansion of the ProgressBar, it is more than the progress bar a function is a drag, so that users can control the progress bar, such as playing movies, users can drag Seekbar for fast forward and fast retreat.
To realize its drag control, it is necessary to monitor the event, the Android system provides a listening interface Seekbar.onseekbarchangelistener, to realize its listening function as long as the implementation of its interface. There are three major events that we need to monitor in Seekbar
The change of the value (onprogresschanged).
Start dragging (Onstarttrackingtouch).
Stop dragging (Onstoptrackingtouch).
The use of Seekbar and button and so the basic no difference, the following first of its properties
Android:max Sets the size of the value.
android:thumb= "@drawable/" the drag icon displayed, if not set this parameter is the system default, if you need to redefine the
new definition, the icon you want to store in the resource directory/res/drawable, and then call it.
Android:thumboffset Drag the icon's offset value to allow the drag icon to exceed the bar's length.
Android:progress sets Seekbar the current default value, ranging from 0 to max.
Android:secondaryprogress used the Thunder all know dragging the icon to move around with the current playback time, we also note that there is
also a buffer to see the progress bar, this property is used to set the default display value of how much, the range is 0 to max.
Android:progressdrawable when we do not want to use the system default Seekbar, we can define one ourselves, this resource file is used to
call
Our own definition of the Seekbar icon is generally created under the drawable of an. xml file s with layer-list to organize these icons.
The following figure is a custom Seekbar
Implementing Seekbar Code:
<seekbar
android:id= "@+id/seek_bar"
android:layout_width= "Fill_parent"
Wrap_content "
android:progressdrawable=" @drawable/myseekbar_drawable "
android:thumb=" @drawable/my_seek _thumb " />
myseekbar_drawable file
<?xml version= "1.0" encoding= "UTF-8"?> <layer-list xmlns:android=
"http://schemas.android.com/" Apk/res/android ">
<item
android:id=" @android: Id/background "
android:drawable=" @drawable SEEK_BG " /><!--The blue part of the lowest picture instance-->
<item
android:id=" @android: Id/secondaryprogress "
android:drawable= "@drawable/seek_pro" /><!--Show the second progress of the instance green part--
>
<item
Android:id= "@android: id/progress"
android:drawable= "@drawable/seek_bar" /><!-- The picture showing the current progress is the white part above the instance
-->
</layer-list>