Lak*_*Lak 4 animation android duration splash-screen imageview
在我的 Android 应用程序中,我有一个闪屏,它会闪烁应用程序的徽标 3 秒钟,然后启动登录活动。这是我的代码:
imgView.postDelayed(new Runnable() {
@Override
public void run() {
final Animation animation = new AlphaAnimation(1, 0);
animation.setDuration(1000);
animation.setInterpolator(new LinearInterpolator());
animation.setRepeatCount(Animation.INFINITE);
animation.setRepeatMode(Animation.REVERSE);
imgView.startAnimation(animation);
}
}, 3000);
Intent intent = new Intent(SplashscreenActivity.this,LoginActivity.class);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
但图像无限闪烁。如何让3秒后停止眨眼?我参考了一些帖子,但无法得到确切的答案。
你可以试试这个
final Animation animation = new AlphaAnimation(1, 0);
animation.setDuration(1000);
animation.setInterpolator(new LinearInterpolator());
animation.setRepeatCount(Animation.INFINITE);
animation.setRepeatMode(Animation.REVERSE);
imgView.startAnimation(animation);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
animation .cancel();
Intent intent = new Intent(SplashscreenActivity.this, LoginActivity.class);
startActivity(intent);
}
}, 3000);
Run Code Online (Sandbox Code Playgroud)
您可以使用imgView.clearAnimation()代替animation.cancel();
我希望这能帮到您。谢谢
| 归档时间: |
|
| 查看次数: |
2252 次 |
| 最近记录: |