Android three ways to implement a custom circular progress bar ProgressBar

Source: Internet
Author: User

First, through the animation to achieve

The definition res/anim/loading.xml is as follows:

<?xml version="1.0"encoding="UTF-8"?> <animation-list android:oneshot="false"xmlns:android="http://schemas.android.com/apk/res/android"> <item android:duration=" Max"android:drawable="@drawable/loading_01"/> <item android:duration=" Max"android:drawable="@drawable/loading_02"/> <item android:duration=" Max"android:drawable="@drawable/loading_03"/> <item android:duration=" Max"android:drawable="@drawable/loading_04"/> <item android:duration=" Max"android:drawable="@drawable/loading_05"/> <item android:duration=" Max"android:drawable="@drawable/loading_06"/> <item android:duration=" Max"android:drawable="@drawable/loading_07"/> </animation-list>

Second, through the custom color implementation

The definition res/drawable/progress_small.xml is as follows:

<?xml version="1.0"encoding="Utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android"android:fromdegrees="0"Android:pivotx="50%"Android:pivoty="50%"android:todegrees=" the"> <Shape Android:innerradiusratio="3"Android:shape="Ring"Android:thicknessratio="8"Android:uselevel="false"> <Gradient Android:centercolor="#FFFFFF"Android:centery="0.50"Android:endcolor="#1E90FF"Android:startcolor="#000000"Android:type="Sweep"Android:uselevel="false"/> </shape> </rotate>

Third, use a picture to customize
The definition res/drawable/progress_small.xml is as follows:

<rotate xmlns:android="http://schemas.android.com/apk/res/android"android:drawable="@drawable/spinner_black_16"Android:pivotx="50%"Android:pivoty="50%"android:fromdegrees="0"android:todegrees=" the"/>

The same method is used, as follows:

<ProgressBar      android:layout_width="wrap_content"      android: Layout_height="wrap_content"      android:indeterminatedrawable= " @drawable/progress_small "/>  

You can also set its size by setting the style as needed! Generally only used when using the default Progrressbar. For the above three customization methods, it is recommended to modify the image size directly, or shape;

<ProgressBar android:layout_width="wrap_content"Android:layout_height="wrap_content"android:layout_centerinparent="true"style="? Android:attr/progressbarstylesmall"android:indeterminatedrawable="@drawable/progress_small"/>

When set to Progressbarstylesmall, the icon becomes smaller.

When set to Progressbarstylelarge, the icon becomes larger

Reference: http://www.eoeandroid.com/forum.php?mod=viewthread&tid=76872

Android three ways to implement a custom circular progress bar 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.