Endore8
Endore8

Reputation: 55

ProgressBar Animation

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?`

Upvotes: 1

Views: 3322

Answers (2)

Akansha patel
Akansha patel

Reputation: 49

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();

Upvotes: 0

Todd Davies
Todd Davies

Reputation: 5522

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.

Upvotes: 1

Related Questions