【问题标题】:How to decrease the speed of custom ProgressBar如何降低自定义 ProgressBar 的速度
【发布时间】:2012-12-24 06:09:00
【问题描述】:

我已经实现了一个自定义进度条,并在从 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%" />

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

任何建议将不胜感激。

【问题讨论】:

    标签: android progress-bar


    【解决方案1】:

    将代码添加到progress.xml

    android:fromDegrees="0"
    
    android:toDegrees="1080"   <!-- Add in code to progress custumize xml to speed up -->
    

    【讨论】:

      【解决方案2】:

      试试这个。它会帮助你。

      创建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" />
      

      【讨论】:

        【解决方案3】:

        使用“旋转”而不是“动画旋转”并更改 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" />
        

        【讨论】:

          猜你喜欢
          • 2022-08-06
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多