Use the. 9 chart to change the SeekBar style, and the. 9 chart SeekBar Style
1. SeekBar in the layout file:
(Progress bar style android: progressDrawable = "@ drawable/seekbar_bg ")
(Drag the android: thumb = "@ drawable/thumb_bar" button to configure the style, such as press status ;)
<SeekBar android:id="@+id/my_seekBar" android:layout_width="300dp" android:layout_height="20dp" android:max="100" android:minHeight="10dp" android:maxHeight="10dp" android:paddingLeft="8dp" android:paddingRight="8dp" android:thumbOffset="5dp" android:layout_centerVertical="true" android:progressDrawable="@drawable/seekbar_bg" android:thumb="@drawable/thumb" />
2. Configure seekbar_bg.xml in the progress bar style file:
<? Xml version = "1.0" encoding = "UTF-8"?> <Layer-list xmlns: android = "http://schemas.android.com/apk/res/android"> <! -- Progress Bar background --> <item android: id = "@ + android: id/background"> <nine-patch android: src = "@ drawable/bar_dn"/> </item> <! -- Second Progress --> <item android: id = "@ + android: id/SecondaryProgress"> <nine-patch android: src = "@ drawable/bar_dn"/> </item> <! -- Progress --> <item android: id = "@ + android: id/progress"> <clip> <nine-patch android: src = "@ drawable/bar_up"/> </clip> </item> </layer-list>
---- The above figure uses the. 9 configuration. If you use the image directly, you can directly configure it as follows:
<layer-list> <item android:id="@+android:id/background" android:drawable="@drawable/bar_dn" /><item android:id="@+android:id/SecondaryProgress" android:drawable="@drawable/bar_dn" /><item android:id="@+android:id/progress" android:drawable="@drawable/bar_up" /></layer-list>
3. Drag the button android: thumb = "@ drawable/thumb" (in the white point)
Schedule .9image (suffixed with .9.png)
Bar_dn.9.png
Bar_up.9.png
How to change the SeekBar style in Android Development
It depends on your theme. Theme. Light is the ugly SeekBar in Figure 2.
How to customize the seekBar style?
Okay, I have almost understood it, but there are still a bunch of attributes that I don't know what it means. What do I mean when I solve these five questions? After testing several pieces of data, I am still confused ....