"Android progress bar" 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:

[HTML]View Plaincopyprint?
  1. <? XML version= "1.0" encoding="UTF-8"?>
  2. <animation-list android:oneshot="false"
  3. xmlns:android="http://schemas.android.com/apk/res/android">
  4. <item android:duration= "android:drawable=" @drawable/loading_01 " />
  5. <item android:duration= "android:drawable=" @drawable/loading_02 " />
  6. <item android:duration= "android:drawable=" @drawable/loading_03 " />
  7. <item android:duration= "android:drawable=" @drawable/loading_04 " />
  8. <item android:duration= "android:drawable=" @drawable/loading_05 " />
  9. <item android:duration= "android:drawable=" @drawable/loading_06 " />
  10. <item android:duration= "android:drawable=" @drawable/loading_07 " />
  11. </animation-list>



Second, through the custom color implementation

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

[HTML]View Plaincopyprint?
  1. <? XML version= "1.0" encoding="Utf-8"?>
  2. <rotate xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:fromdegrees="0"
  4. android:pivotx="50%"
  5. android:pivoty="50%"
  6. android:todegrees= " > "
  7. <shape
  8. android:innerradiusratio="3"
  9. android:shape="Ring"
  10. android:thicknessratio="8"
  11. android:uselevel="false" >
  12. <gradient
  13. android:centercolor="#FFFFFF"
  14. android:centery="0.50"
  15. android:endcolor="#1E90FF"
  16. android:startcolor="#000000"
  17. android:type="Sweep"
  18. android:uselevel="false" />
  19. </shape>
  20. </rotate>


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

[HTML]View Plaincopyprint?
  1. <rotate xmlns:android="http://schemas.android.com/apk/res/android"
  2. android:drawable="@drawable/spinner_black_16"
  3. android:pivotx="50%"
  4. android:pivoty="50%"
  5. android:fromdegrees="0"
  6. android:todegrees=" /> "



The same method is used, as follows:

[HTML]View Plaincopyprint?
    1. <ProgressBar
    2. android:layout_width="wrap_content"
    3. android:layout_height="wrap_content"
    4. 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;

[HTML]View Plaincopyprint?
    1. <progressbar   
    2.     android:layout_width=" wrap_content "&NBSP;&NBSP;
    3.     android:layout_height= "wrap_content" &NBSP;&NBSP;
    4.     android:layout_centerinparent=
    5.     style= "Android: Attr/progressbarstylesmall "&NBSP;&NBSP;
    6.      "@drawable/progress_small" />   


When set to Progressbarstylesmall, the icon becomes smaller.

When set to Progressbarstylelarge, the icon becomes larger

Original: http://blog.csdn.net/feng88724/article/details/7409032

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.