Use the. 9 chart to change the SeekBar style, and the. 9 chart SeekBar Style

Source: Internet
Author: User

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 ....
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.