Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fade out when progressBar disappear

I would like to make a progress bar disappear with a fade. I already saw this on other applications like the well-known SuperSU.

But I don't know how to do it.

EDIT: Here is what I did:

AlphaAnimation fadeOut = new AlphaAnimation(1.0f, 0.0f);
fadeOut.setDuration(500);
fadeOut.setFillAfter(true);
progressBar.startAnimation(fadeOut);
progressBar.setVisibility(ProgressBar.GONE);

listview.setAdapter(new MyAdapter(getApplicationContext(), listGroups, listChildren));

listview.setVisibility(ListView.VISIBLE);
AlphaAnimation fadeIn = new AlphaAnimation(0.0f, 1.0f);
fadeIn.setDuration(500);
fadeIn.setFillAfter(true);
listview.startAnimation(fadeIn);

When I start another intent and then go back, sometimes (this is quite odd, it seems to be random) the progress bar is above the listview and is frozen (not animated).

Nobody can help me? :( I tried this:

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

    if(listview.getVisibility() == ListView.VISIBLE)
        progressBar.setVisibility(ProgressBar.GONE);
}

It did not work, I still got the progress bar frozen in the middle of the listview...

like image 764
vital Avatar asked Dec 16 '22 19:12

vital


1 Answers

AlphaAnimation fadeOutAnimation = new AlphaAnimation(1.0f, 0.0f);//fade from 1 to 0 alpha
fadeOutAnimation.setDuration(1000);
fadeOutAnimation.setFillAfter(true)//to keep it at 0 when animation ends
myProgressBar.startAnimation(fadeOutAnimation);
like image 124
LuxuryMode Avatar answered Dec 27 '22 10:12

LuxuryMode