Android Custom Landscape ProgressBar

Source: Internet
Author: User

Less nonsense, first look at the effect of it, the color is a bit ugly, but the basic functions are mentioned, the actual use of modified on OK.

Actually very simple, on the code!

Create Drawable folder under Res, new file Drawable/progressbar_color.xml

<?xml version= "1.0"  encoding= "Utf-8"? ><layer-list xmlns:android= "http// Schemas.android.com/apk/res/android " >    <!--  background   gradient is a gradient, Corners defines rounded corners  -->    <item android:id= "@android: Id/background" >         <shape>             <corners android:radius= "10DP"  />             <solid android:color= "#ffffff"  />         </shape>    </item>    <!--  Second progress bar color  -->    <item android:id= "@android: Id/secondaryprogress" >         <clip>             <shape>                <corners  android:radius= "10dip"  />                 <gradient                     android:angle= "90.0"                      android:centercolor= "#ac6079"                      android:centery= "0.45"                      android:endcolor= "#6c213a"                      android:startcolor= "# e71a5e " />            </shape>         </clip>    </item>    <!--  progress bar  -- >    <item android:id= "@android: Id/progress" >         <clip>            < shape>                < corners android:radius= "10dip"  />                 <solid android:color= "#FF8080"  />             </shape>         </clip>    </item></layer-list>

Then refer to it in the layout.

Activity_main.xml

<progressbar android:id= "@+id/my_progress" android:layout_width= "Match_parent" Android:layout_hei ght= "12DP" android:max= "android:progress=" "android:secondaryprogress=" "style="? Android Oid:attr/progressbarstylehorizontal "android:progressdrawable=" @drawable/progressbar_color "/>

After the operation is the above effect.

Android Custom Landscape ProgressBar

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.