自定义循环进度条不能正常工作

时间:2016-06-23 17:04:27

标签: android progress-bar custom-controls

我从互联网下载此代码(最后我设置了链接)

用于自定义颜色循环进度条

但圆形进度条不旋转 我错过了什么吗? 进度条是“静态”

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:id="@android:id/secondaryProgress">
        <shape
            android:innerRadiusRatio="3"
            android:shape="ring"
            android:useLevel="true"
            android:thicknessRatio="14.0">

            <gradient
                android:startColor="@color/colorBlanco"
                android:endColor="@color/colorBlanco"
                android:centerColor="@color/colorBlanco"
                android:type="sweep" />
        </shape>
    </item>
    <item android:id="@android:id/progress">
        <rotate
            android:fromDegrees="270"
            android:pivotX="50%"
            android:pivotY="50%"
            android:toDegrees="270" >
            <shape
                android:innerRadiusRatio="3"
                android:shape="ring"
                android:useLevel="true"
                android:thicknessRatio="14.0">
                <rotate
                    android:fromDegrees="0"
                    android:toDegrees="360"
                    android:pivotX="50%"
                    android:pivotY="50%" />
                <gradient
                    android:startColor="@color/colorAzul"
                    android:endColor="@color/colorAzul"
                    android:centerColor="@color/colorAzul"
                    android:type="sweep" />
            </shape>
        </rotate>
    </item>
</layer-list>

此代码包含我的启动器

<ProgressBar
    android:layout_gravity="center"
    android:id="@+id/circularProgressbar"
    android:layout_width="100dp"
    android:layout_height="100dp"
    style="?android:attr/progressBarStyleHorizontal"
    android:indeterminate="false"
    android:progress="80"
    android:max="100"
    android:secondaryProgress="100"
    android:layout_below="@+id/img_logo_app_launcher"
    android:progressDrawable="@drawable/custom_progressbar" />

Horizontal and Circular Progress Bar in Android

1 个答案:

答案 0 :(得分:0)

progressBar.setIndeterminateDrawable()设置为任何可绘制文件 将您的移动装载机替换为定义的运动图像。