图像视图动画
我正在研究图像动画的顺序。这是我的 java 活动文件。
对于每个图像视图,我使用 fadein、fadeout xml。但我无法以线程方式一一获取该动画。
package com.cardio.android;
import android.app.Activity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
public class guide extends Activity {
//create name of animation
Animation myFadeInAnimation;
Animation myFadeOutAnimation;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//grab the imageview and load the animations
ImageView myImageView = (ImageView) findViewById(R.id.imageView1);
ImageView myImageView1 = (ImageView) findViewById(R.id.imageView2);
ImageView myImageView2 = (ImageView) findViewById(R.id.imageView3);
ImageView myImageView3 = (ImageView) findViewById(R.id.imageView4);
ImageView myImageView4 = (ImageView) findViewById(R.id.imageView5);
Animation myFadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.fadein);
Animation myFadeOutAnimation = AnimationUtils.loadAnimation(this, R.anim.fadeout);
Animation myFadeInAnimation1 = AnimationUtils.loadAnimation(this, R.anim.fadein1);
Animation myFadeOutAnimation1 = AnimationUtils.loadAnimation(this, R.anim.fadeout1);
Animation myFadeInAnimation2 = AnimationUtils.loadAnimation(this, R.anim.fadein2);
Animation myFadeOutAnimation2 = AnimationUtils.loadAnimation(this, R.anim.fadeout2);
Animation myFadeInAnimation3 = AnimationUtils.loadAnimation(this, R.anim.fadein3);
Animation myFadeOutAnimation3 = AnimationUtils.loadAnimation(this, R.anim.fadeout3);
Animation myFadeInAnimation4 = AnimationUtils.loadAnimation(this, R.anim.fadein4);
Animation myFadeOutAnimation4 = AnimationUtils.loadAnimation(this, R.anim.fadeout4);
//fade it in, and fade it out.
myImageView.startAnimation(myFadeInAnimation);
myImageView.startAnimation(myFadeOutAnimation);
myImageView1.startAnimation(myFadeInAnimation1);
myImageView1.startAnimation(myFadeOutAnimation1);
myImageView2.startAnimation(myFadeInAnimation2);
myImageView2.startAnimation(myFadeOutAnimation2);
myImageView3.startAnimation(myFadeInAnimation3);
myImageView3.startAnimation(myFadeOutAnimation3);
myImageView4.startAnimation(myFadeInAnimation4);
myImageView4.startAnimation(myFadeOutAnimation4);
}
}
I am working on sequential order of image animations. Here is my java activity file.
For each imageview i am using fadein, fadeout xml. But i could not able to get this animations one by one in a threading manner.
package com.cardio.android;
import android.app.Activity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
public class guide extends Activity {
//create name of animation
Animation myFadeInAnimation;
Animation myFadeOutAnimation;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//grab the imageview and load the animations
ImageView myImageView = (ImageView) findViewById(R.id.imageView1);
ImageView myImageView1 = (ImageView) findViewById(R.id.imageView2);
ImageView myImageView2 = (ImageView) findViewById(R.id.imageView3);
ImageView myImageView3 = (ImageView) findViewById(R.id.imageView4);
ImageView myImageView4 = (ImageView) findViewById(R.id.imageView5);
Animation myFadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.fadein);
Animation myFadeOutAnimation = AnimationUtils.loadAnimation(this, R.anim.fadeout);
Animation myFadeInAnimation1 = AnimationUtils.loadAnimation(this, R.anim.fadein1);
Animation myFadeOutAnimation1 = AnimationUtils.loadAnimation(this, R.anim.fadeout1);
Animation myFadeInAnimation2 = AnimationUtils.loadAnimation(this, R.anim.fadein2);
Animation myFadeOutAnimation2 = AnimationUtils.loadAnimation(this, R.anim.fadeout2);
Animation myFadeInAnimation3 = AnimationUtils.loadAnimation(this, R.anim.fadein3);
Animation myFadeOutAnimation3 = AnimationUtils.loadAnimation(this, R.anim.fadeout3);
Animation myFadeInAnimation4 = AnimationUtils.loadAnimation(this, R.anim.fadein4);
Animation myFadeOutAnimation4 = AnimationUtils.loadAnimation(this, R.anim.fadeout4);
//fade it in, and fade it out.
myImageView.startAnimation(myFadeInAnimation);
myImageView.startAnimation(myFadeOutAnimation);
myImageView1.startAnimation(myFadeInAnimation1);
myImageView1.startAnimation(myFadeOutAnimation1);
myImageView2.startAnimation(myFadeInAnimation2);
myImageView2.startAnimation(myFadeOutAnimation2);
myImageView3.startAnimation(myFadeInAnimation3);
myImageView3.startAnimation(myFadeOutAnimation3);
myImageView4.startAnimation(myFadeInAnimation4);
myImageView4.startAnimation(myFadeOutAnimation4);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用 onAnimationEnd 事件并在其中触发下一个动画。您可以创建一个循环来执行此操作,也可以将它们嵌套在一起:
You need to use onAnimationEnd event and in it trigger the next animation. You can create a loop to do it or just nest them into each other: