2012-09-09 34 views
3

我想使進度條消失而消失。我已經看到了其他應用程序,如着名的SuperSU。當progressBar消失時淡出

但我不知道該怎麼做。

編輯: 這裏是我做過什麼:

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

當我開始另一個意圖再回去,有時候(這是很奇怪的,這似乎是隨機的)進度條的列表視圖上方並被凍結(而不是動畫)。

沒人能幫幫我嗎? :( 我嘗試這樣做:

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

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

它沒有工作,我仍然有在ListView中間凍結的進度條...

+0

看到我的編輯上面 – lost17

回答

8
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); 
+0

嗡嗡聲......現在有些奇怪的事情發生。當我開始另一個意圖然後回去時,有時(這很奇怪,它似乎是隨機的),進度條在列表視圖上方並且被凍結(而不是動畫)。 我確實把這一行:fadeOutAnimation.setFillAfter(true) – lost17

3

進度條是View和意見可以使用Animations,您正在尋找AlphaAnimation

創建和啓動的動畫漸變:

AlphaAnimation fadeOut; 
fadeOut = new AlphaAnimation(1,0); //fade out animation from 1 (fully visible) to 0 (transparent) 
fadeOut.setDuration(1000); //set duration in mill seconds 
fadeOut.setFillAfter(true); 
progresBar.startAnimation(fadeOut);