2017-07-18 42 views
1

我正在嘗試做一個圓形的進度條運行順利,但我沒有結果。進度條應該根據定時器值更新。自定義進度條不能順利更新

這裏是我動畫進度,

int progress = (int)(this.mCurrentTimerValue/1000); 
this.mProgressBarAnimation = ObjectAnimator.ofInt(this.mProgressBar,"progress",progress); 
this.mProgressBarAnimation.setDuration(this.mCurrentTimerValue); 
this.mProgressBarAnimation.setInterpolator(new LinearInterpolator()); 

其中this.mCurrentTimerValue是時間以ml。在這個例子中是10000

這裏是結果,

enter image description here

我想順利顯示進度,但我不能。我試着用ObjectAnimator.ofFloat,因爲問題可能是我試圖在整數空間進步,但在這種情況下動畫不起作用。

這裏是我定製的進度條,

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 
<item android:id="@android:id/progress"> 
    <rotate 
     android:fromDegrees="270" 
     android:toDegrees="270" 
     android:pivotX="50%" 
     android:pivotY="50%" > 
     <shape 
      android:innerRadiusRatio="2.5" 
      android:shape="ring" 
      android:thicknessRatio="25.0" > 
      <gradient 
       android:centerColor="@color/yellow" 
       android:endColor="@color/yellow" 
       android:startColor="@color/yellow" 
       android:type="sweep" /> 
     </shape> 
    </rotate> 
</item> 
<item android:id="@android:id/secondaryProgress"> 
    <rotate 
     android:fromDegrees="270" 
     android:toDegrees="270" 
     android:pivotX="50%" 
     android:pivotY="50%" > 
     <shape 
      android:innerRadiusRatio="2.5" 
      android:shape="ring" 
      android:thicknessRatio="25.0" > 
      <gradient 
       android:centerColor="@color/green" 
       android:endColor="@color/green" 
       android:startColor="@color/green" 
       android:type="sweep" /> 
     </shape> 
    </rotate> 
</item> 

<ProgressBar 
     style="?android:attr/progressBarStyleHorizontal" 
     android:layout_width="300dp" 
     android:layout_height="300dp" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:indeterminate="false" 
     android:progress="100" 
     android:progressDrawable="@drawable/custom_progress_bar" /> 

我閱讀這些問題,但沒有幫助我,

回答

0

如果有人需要針對這種情況的解決方案,幫助this answer我,但我承認我不認爲是最好的。