我正在尝试使用启动屏幕来覆盖 Google Map 加载延迟(对于 Maps v2)。
我想使用应该在几秒钟后淡出的ImageView
inFrameLayout
并且能够覆盖onAnimationEnd
以隐藏启动屏幕的ImageView
.
当没有延迟地开始动画时,onAnimationEnd
被适当地调用:
new Animations().animateAlphaForLayout(splashLayout, 2000);
问题是当我尝试启动动画时postDelayed
根本onAnimationEnd
没有调用:
splashLayout.postDelayed(new Runnable() {
@Override
public void run() {
new Animations().animateAlphaForLayout(splashLayout, 2000);
}
}, 3000);
类的Animations
代码是这样的:
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.LayoutAnimationController;
public class Animations {
public void animateAlphaForLayout(final ViewGroup viewGroup, int duration) {
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(1.0f, 0.0f);
animation.setRepeatCount(0);
animation.setFillAfter(true);
animation.setDuration(duration);
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
viewGroup.setVisibility(View.GONE);
}
});
set.addAnimation(animation);
LayoutAnimationController controller = new LayoutAnimationController(set, 0.0f);
viewGroup.setLayoutAnimation(controller);
}
}
有谁知道为 Android 2.3 及更高版本(API 10+)执行此操作的方法?
谢谢!