开发者

Android ProgressBar not animating

开发者 https://www.devze.com 2023-01-13 12:17 出处:网络
I\'m drawing a ProgressBar in a custom View (SurfaceView) to it\'s Canvas, and it\'s drawn as expected. Except that it\'s not animating, no matter what I do.

I'm drawing a ProgressBar in a custom View (SurfaceView) to it's Canvas, and it's drawn as expected. Except that it's not animating, no matter what I do. My custom view is animated properly, but I cant change the progress of the ProgressBar.

I've created the ProgressBar like this:

mImageProgressbar = new ProgressBar(context);
mImageProgressbar.setIndeterminate(tru开发者_StackOverflow社区e);
int pad = 50;
mImageProgressbar.setPadding(pad, pad, pad, pad);
mImageProgressbar.layout(0, 0, 200, 200);
mImageProgressbar.setEnabled(true);

And I draw it something like this (slightly simplified):

Canvas c = mSurfaceHolder.lockCanvas(null);
mImageProgressbar.draw(c);

And I've tried updating it's progress manually as well:

mImageProgressbar.setProgress( (int)(System.currentTimeMillis()%1000) );

Any ideas on what I need to do in order for my ProgressBar to animate or change it's progress would be appreciated.


Have you tried to invalidate the progressBar view?

mImageProgressbar.invalidate();


You have to use a Thread to update a progressbar in realtime

0

精彩评论

暂无评论...
验证码 换一张
取 消