ProgressBar not running smoothly loolipop

523 views Asked by At

I have an indeterminate progress bar that does not run smoothly, the ui thread isn't freezing so probably it's not something that is caused by running a long operaton on ui thread ( I have asynctask ). I am using the latest build tools 22.01 and the target SDK is also 22 and I'm using support library with appcomp. For some reason when the application gets onPause and onResume the progress bar gets back to normal. The devices I test on are nexus 4 and htc1.

videos :

smooth progressBar > not smooth progressBar >

1

There are 1 answers

0
Eliyahu Shwartz On

After I look through the source code of ProgressBar i saw that a setVisibilty and onVisibilityChanged start and stop the animation accordingly

public void setVisibility(int v) {
    if (getVisibility() != v) {
        super.setVisibility(v);

        if (mIndeterminate) {
            // let's be nice with the UI thread
            if (v == GONE || v == INVISIBLE) {
                stopAnimation();
            } else {
                startAnimation();
            }
        }
    }
}

so i made a call manually as follow

@Override
public void onResume() {
    super.onResume();

    progressBar.setVisibility(View.INVISIBLE);
    progressBar.setVisibility(View.VISIBLE);

and this solve the problem ...