Android 在ImageView的位图中循环
通过python中的Flask,我向Android应用程序发送了多个图像,并将它们存储到位图的ArrayList中 如何在无限循环的淡出/淡入动画中自动循环它们?是的,您可以执行以下操作:(在这里,对于演示,我使用了一个可绘制数组。您可以使用位图数组代替此数组,或者使用此数组进行演示。)Android 在ImageView的位图中循环,android,imageview,Android,Imageview,通过python中的Flask,我向Android应用程序发送了多个图像,并将它们存储到位图的ArrayList中 如何在无限循环的淡出/淡入动画中自动循环它们?是的,您可以执行以下操作:(在这里,对于演示,我使用了一个可绘制数组。您可以使用位图数组代替此数组,或者使用此数组进行演示。) 意味着你想一个接一个地显示位图数组中的所有图像,对吗?是的,如果可能的话,以随机顺序显示每个图像,使它们淡入淡出好的,明白了。在下面给你一个答案。@ArjunLotay现在你有什么疑问吗?或者明白了。等我回到笔
意味着你想一个接一个地显示位图数组中的所有图像,对吗?是的,如果可能的话,以随机顺序显示每个图像,使它们淡入淡出好的,明白了。在下面给你一个答案。@ArjunLotay现在你有什么疑问吗?或者明白了。等我回到笔记本电脑上,我会试一试的,谢谢你的帮助response@ArjunLotay请随时告诉我您的任何疑问,我会帮助您。@ArjunLotay如果您满意,请接受这个答案。这将帮助其他人做同样的事情。
public class Main3Activity extends AppCompatActivity {
private ImageView imageView;
private int imageArray[] = { R.drawable.ic_launcher_background, R.drawable.ic_launcher_background,R.drawable.ic_launcher_background };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main3);
imageView = (ImageView) findViewById(R.id.imageView);
startAnimation();
}
private void startAnimation() {
int fadeInDuration = 500;
int timeBetween = 3000;
int fadeOutDuration = 1000;
int random = new Random().nextInt((imageArray.length - 1) + 1);
imageView.setVisibility(View.INVISIBLE);
imageView.setImageResource(imageArray[random]);
Animation fadeIn = new AlphaAnimation(0, 1);
fadeIn.setInterpolator(new DecelerateInterpolator());
fadeIn.setDuration(fadeInDuration);
Animation fadeOut = new AlphaAnimation(1, 0);
fadeOut.setInterpolator(new AccelerateInterpolator());
fadeOut.setStartOffset(fadeInDuration + timeBetween);
fadeOut.setDuration(fadeOutDuration);
AnimationSet animation = new AnimationSet(false);
animation.addAnimation(fadeIn);
animation.addAnimation(fadeOut);
animation.setRepeatCount(1);
imageView.setAnimation(animation);
animation.setAnimationListener(new Animation.AnimationListener() {
public void onAnimationEnd(Animation animation) {
startAnimation();
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationStart(Animation animation) {
}
});
}
}