I'm trying to do a circular progress bar run smoothly but I'm not having result. The progress bar should be update in function of a timer value.
Here is how I animate the progressbar,
int progress = (int)(this.mCurrentTimerValue/1000);
this.mProgressBarAnimation = ObjectAnimator.ofInt(this.mProgressBar,"progress",progress);
this.mProgressBarAnimation.setDuration(this.mCurrentTimerValue);
this.mProgressBarAnimation.setInterpolator( new LinearInterpolator());
where this.mCurrentTimerValue is the time in ml. For this example is 10000
And here is the result,
I want to show the progress smoothly but I can't. I tried with ObjectAnimator.ofFloat because the problem maybe is that I'm trying to progress in integer spaces but in that case animation doesn't work.
Here is how I customized the progress bar,
<?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" />
I read these questions but didn't help me,
If somebody need a solution for this situation, this answer helped me but I admit I don't think is the best.