如何自定义圆形进度条的颜色?

如何自定义圆形进度条的颜色?

问题描述:

我使用Android上的圆形进度条。我想改变这种颜色。我使用

I am using circular progress bar on Android. I wish to change the color of this. I am using

"?android:attr/progressBarStyleLargeInverse" 

风格。那么如何改变进度条的颜色。

style. So how to change the color of progress bar.

如何自定义风格?此外,什么是风格?

How to custom the style?? Furthermore, what is the definition of the style??

在此先感谢。

请在水库Directory中的一个XML文件,并把progress.xml文件在里面。

Make one xml folder in res directory and put the progress.xml file in it .

    <?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0"
    android:toDegrees="360">
    <shape android:shape="ring" android:innerRadiusRatio="3"
        android:thicknessRatio="8" android:useLevel="false">

        <size android:width="76dip" android:height="76dip" />
        <gradient android:type="sweep" android:useLevel="false"
            android:startColor="#447a29" 
            android:endColor="#447a29"
            android:angle="0"
             />
    </shape>
</rotate> 

设置startColor和endColor根据您的选择。

set startColor and endColor as per your choice .

现在设置progress.xml在进度条的backgound。

now set that progress.xml in progressbar's backgound .

<ProgressBar
  android:id="@+id/ProgressBar01" 
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:background ="@xml/progress">