The color setting of the Android ProgressBar horizontal progress bar

Source: Internet
Author: User

The Android system provides the style of the horizontal progress bar ProgressBar, which is almost impossible to use in the actual development, because it is "too ugly" ^_^

So we need to customize the color for more, and the main use is to customize the style file.


You can set the default background color and the color of the progress bar by adding the Progressbar.xml file in the drawable directory.

(It is worth mentioning that support for gradient color)

Code:

<layer-list xmlns:android= "Http://schemas.android.com/apk/res/android" > <item android:id= "@android: ID/                Background "> <shape> <corners android:radius=" 5dip "/> <gradient                android:angle= "0" android:centercolor= "#ff5a5d5a" android:centery= "0.75"    Android:endcolor= "#ff747674" android:startcolor= "#ff9d9e9d"/> </shape> </item> <item android:id= "@android: id/secondaryprogress" > <clip> <shape> < Corners android:radius= "5dip"/> <gradient android:angle= "0" an                    Droid:centercolor= "#80ffb600" android:centery= "0.75" android:endcolor= "#a0ffcb00" Android:startcolor= "#80ffd300"/> </shape> </clip> </item> & Lt;item android:id= "@android: ID/progress "> <clip> <shape> <corners android:radius=" 5dip "/>                    <gradient android:angle= "0" android:endcolor= "#8000ff00"  Android:startcolor= "#80ff0000"/> </shape> </clip> </item></layer-list>

The layout file is defined as follows:

                        <progressbar                android:id= "@+id/progressbar"                style= "? Android:attr/progressbarstylehorizontal                " Android:layout_width= "Fill_parent"                android:layout_height= "7.5DP"                android:max= "Android"                : progress= "android:layout_marginright="                 8dp "android:progressdrawable="                @drawable/progressbar "                 android:visibility= "Visible"/>



The color setting of the Android ProgressBar horizontal progress bar

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.