Android进度条填写

时间:2013-03-28 12:25:03

标签: java android progress-bar gradient radial

我想要一个圆形的加载栏。我想用一个整数来填充它我试过这个

 <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"

        android:indeterminateDrawable="@xml/progress" >
    </ProgressBar>

progress.xml:

<?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="360" >

<shape
    android:innerRadiusRatio="3"
    android:shape="ring"
    android:thicknessRatio="8"
    android:useLevel="false" >
    <size
        android:height="48dip"
        android:width="48dip" />

    <gradient

        android:centerY="0.50"
        android:endColor="#000000"
        android:startColor="#ffffff"
        android:gradientRadius="20"
        android:type="radial"
        android:useLevel="false" />
</shape>

和我的活动

    protected void onPostExecute(Void result) {

            bar.setProgress(50);
            bar.setMax(100);
            bar.setVisibility(View.VISIBLE);
    }

圆圈保持黑色。如果我将渐变类型设置为扫描,则圆圈将填充startcolor black和endcolor white ..并且它会不断重复。

但是我想要将圆圈填充一次..所以它开始变黑并填充白色;只有一次..

这可能吗?

我想达到这个结果:

http://ultimateprogrammingtutorials.blogspot.be/2013/02/how-to-draw-circular-progress-bar-in.html

2 个答案:

答案 0 :(得分:2)

here是CircularProgressBar的一个很好的例子,根据你的要求希望这可以帮助你

答案 1 :(得分:1)

相关问题