A tentative approach to Android custom style---progressbar

Source: Internet
Author: User

The system comes with ProgressBar too ugly, so I decided to customize a style.

The original style

<?xml version= "1.0" encoding= "Utf-8"?>
<layer-list xmlns:android= "Http://schemas.android.com/apk/res/android" >
<item android:id= "@android: Id/background" >
<shape >
<corners android:radius= "5DP" >

</corners>
<gradient
Android:startcolor= "#ff9d9e9d"
Android:centercolor= "#ff5a5d5a"
android:centery= "0.75"
Android:endcolor= "#ff747674"
Android:angle= "270"
/>

</shape>

</item>

<item android:id= "@android: Id/secondaryprogress" >
<clip
>
<shape>
<corners android:radius= "5DP"/>
<gradient
Android:startcolor= "#80ffd300"
Android:centercolor= "#80ffb600"
android:centery= "0.75"
Android:endcolor= "#a0ffcb00"
Android:angle= "270"
/>
</shape>
</clip>
</item>

<item android:id= "@android: Id/progress" >
<clip>
<shape>
<corners android:radius= "5DP" ></corners>
<gradient
Android:startcolor= "#ffffd300"
Android:centercolor= "#ffffb600"
android:centery= "0.75"
Android:endcolor= "#ffffcb00"
Android:angle= "270"
/>
</shape>
</clip>

</item>

</layer-list>


After customization:

Progressbarcolor.xml
<?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/bg_progress"
>

</item>
<item android:id= "@android: Id/secondaryprogress" >
<clip
>
<shape>
<corners android:radius= "5DP"/>
<gradient
Android:startcolor= "#80ffd300"
Android:centercolor= "#80ffb600"
android:centery= "0.75"
Android:endcolor= "#a0ffcb00"
Android:angle= "270"
/>
</shape>
</clip>
</item>

<item android:id= "@android: Id/progress" android:drawable= "@drawable/draw_progress" >


</item>

</layer-list>


<style name="My_pb_style" parent="@android: Style/widget.progressbar.horizontal" >        <  Name="android:progressdrawable" > @drawable/progressbarcolor</</style>  

Of these, two images are required:

The focus is on how the style of the system is implemented, and then its own imitation, in this way of learning.

A tentative approach to Android custom style---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.