1

I want to use different animations in one ProgressBar. Code for init and set animation:

progressBar = (ProgressBar) this.view.findViewById(R.id.progressBar);
progressBar.setIndeterminate(true);
progressBar.setIndeterminateDrawable(this.getResources().getDrawable(R.anim.progress_small));

When I want only this code, everything is working well, but when I set new animation by

 `progressBar.setIndeterminateDrawable(this.getResources().getDrawable(R.anim.progress_small))`

it doesn't work. How to use one ProgressBar for more animation?`

Vipul
  • 27,808
  • 7
  • 60
  • 75
Endore8
  • 55
  • 2
  • 5

2 Answers2

1

You are retrieving an animation from the resources with getDrawable().

I may be mistaken, but I don't think there is a way to 'animate' progress changes in a progress bar other than changing the progress very quickly in steps to your desired value. I wrote some sample code for a similar question.

Community
  • 1
  • 1
Todd Davies
  • 5,484
  • 8
  • 47
  • 71
0
progress.setProgressDrawable(getActivity().getResources().getDrawable(R.drawable.graph_blue_green));
ObjectAnimator anim = ObjectAnimator.ofInt(progress, "progress", 0, 5000);
anim.setDuration(1000);
anim.setInterpolator(new DecelerateInterpolator());
anim.start();
GYaN
  • 2,327
  • 4
  • 19
  • 39
  • While this code may answer the question, providing additional context regarding why and/or how this code answers the question improves its long-term value. – rollstuhlfahrer Apr 06 '18 at 07:05