如何动画陆续在Android的一张图像 [英] How to animate images one after another in android

查看:115
本文介绍了如何动画陆续在Android的一张图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我描绘的公司标志,名称和口号三幅图像。我想在一个标志出现,然后再名称,然后口号这样的方式来制作动画这三个图像。这三个动画后,我想在屏幕上消失,并显示一个新的活动。如何做到这一点?请帮我。

I have three images that depicts the company logo, name and slogan. I want to animate these three images in such a way that a logo appears first, then the name and then the slogan. After these three animations, I want the screen to disappear and display a new activity. How to do this? Please help me.

推荐答案

添加一个侦听您的第一个动画,并在方法: onAnimationEnd(),然后启动你的第二个第二图像的动画,等
例如:

add a listener your first animation , and in the method : onAnimationEnd() , then launch your second animation of the second image , and so on Example :

注意:您的初始化和IMG2知名度IMG3为 GONE

NOTE : initialise your img2 and img3 visibility to GONE

public class YourActivity extends Activity implements AnimationListener{
......
@Override 
public void onCreate( Bundle savedInstanceState){
super.onCreate(savedInstanceState);
....

ScaleAnimation a1 , a2 , a3;
//define your animations 
a1 = new ScaleAnimation(0.0f,1.0f);
a2 = new ScaleAnimation(0.0f,1.0f);
a3 = new ScaleAnimation(0.0f,1.0f);

// duration and behavior of ur animations
a1.setFillAfter(true);
a1.setDuration(1000);
a2.setFillAfter(true);
a2.setDuration(1000);
a3.setFillAfter(true);
a3.setDuration(1000);

a1.setAnimationListener(this);
a2.setAnimationListener(this);
a3.setAnimationListener(this);

img1.startAnimation(a1);
}

Override
public void onAnimationEnd(Animation a){
if(a == a1 ){ 
   img2.setVisibility(View.VISIBLE);
   img2.startAnimation(a2);
}

if(a == a2){
   img3.setVisibility(View.VISIBLE);
   img3.startAnimation(a3);
}

if(a == a3){
   startActivity(new Intent(YourActivity.this , SecondActivity.class);
}
}
}

这篇关于如何动画陆续在Android的一张图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆