7

我已经实现了一个自定义进度条,并且在从 URL 获取数据时显示它,它工作正常,因为进度条正在旋转,但我的问题是我目前无法找到降低其旋转速度的适当方法它旋转得非常快。

请帮助我提出您的建议并回复。

进度条的xml布局:-

  <ProgressBar
        android:id="@+id/showProgress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:indeterminateDrawable="@drawable/my_progress_indeterminate" />

这里还有“my_progress_indeterminate”,用于旋转我的自定义进度条:-

<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/image_loading"
    android:pivotX="50%"
    android:pivotY="50%" />

如果可能的话,请分享一些例子来降低旋转速度。

任何建议将不胜感激。

4

3 回答 3

5

将代码添加到progress.xml

android:fromDegrees="0"

android:toDegrees="1080"   <!-- Add in code to progress custumize xml to speed up -->
于 2017-03-19T08:39:27.010 回答
5

尝试这个。它会帮助你。

创建progressbar_custom.xml

/res/drawable/progressbar_custom.xml:

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="3000"
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="360" >

    <shape
        android:innerRadius="18dp"
        android:shape="ring"
        android:thickness="5dp"
        android:useLevel="false" >
        <size
            android:height="48dp"
            android:width="48dp" />

        <gradient
            android:centerColor="#802A67AD"
            android:centerY="0.5"
            android:endColor="#ff2A67AD"
            android:startColor="#002A67AD"
            android:type="sweep"
            android:useLevel="false" />
    </shape>

</rotate>

在 XML 文件中添加进度条

 <ProgressBar
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:indeterminateDrawable="@drawable/progressbar_custom" />
于 2016-12-07T05:36:44.120 回答
1

使用“旋转”而不是“动画旋转”并更改 android:toDegrees 或 android:toDegress 应该让它变慢。

<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/image_loading"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="360" />
于 2014-07-29T04:30:38.443 回答