我想让进度条随着淡入淡出而消失。我已经在其他应用程序(如著名的 SuperSU)上看到了这一点。
但是我不知道怎么做。
编辑: 这是我所做的:
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);
当我开始另一个 Intent 然后返回时,有时(这很奇怪,它似乎是随机的)进度条在 ListView 上方并且被卡住(不是动画)。
没人能帮帮我吗? :( 我试过这个:
@Override
protected void onResume() {
super.onResume();
if(listview.getVisibility() == ListView.VISIBLE)
progressBar.setVisibility(ProgressBar.GONE);
}
它没有用,我的进度条仍然卡住在 ListView 的中间......
最佳答案
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);
关于android - 当 progressBar 消失时淡出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12343388/