Android的ViewFlipper动画 [英] Android ViewFlipper Animation

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

问题描述

我被困在一个简单的问题,这是推动我坚果。基本上我有2 ImageViews,我想拥有的首秀了一秒钟,然后淡出,显示第二。我一直在寻找到使用ViewFlipper,下面的例子code,但动画是不存在的。

I'm stuck on a simple problem which is driving me nuts. Basically I have 2 ImageViews, I'm trying to have the first show for a second, then fade out to show the second. I've been looking into using ViewFlipper, example code below, but the animation is non-existent.

ViewFlipper mFlipper = new ViewFlipper(this);

ImageView i = new ImageView(this);
i.setBackgroundDrawable(getResources().getDrawable(R.drawable.c1));
ImageView i2 = new ImageView(this);
i2.setBackgroundDrawable(getResources().getDrawable(R.drawable.c2));

mFlipper.setInAnimation(AnimationUtils.loadAnimation(this,
        R.anim.fade));
mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this,
        R.anim.fade));
mFlipper.addView(i);
mFlipper.addView(i2);
mFlipper.startFlipping();
setContentView(mFlipper);

我不知道如果我即使在使用viewFlipper所以任何帮助将不胜AP preciated正确的轨道!

I'm not sure if I'm even on the right track using a viewFlipper so any help would be greatly appreciated!

干杯

推荐答案

我看不出有什么问题,您的code,当我使用标准的 android.R.anim.fade_in android.R.anim.fade_out 。这使我相信,这个问题必须与你的淡入淡出动画;请尝试使用内置Android变淡,看看有没有什么帮助。

I see no problems with your code, when I use the standard android.R.anim.fade_in and android.R.anim.fade_out. This leads me to believe that the issue has to do with your fade animations; try using the built-in Android fades and see if that helps.

此外,你应该使用 ImageView.setImageResource() ImageView.setImageDrawable(),而不是 ImageView.setBackgroundDrawable()

Also, you should be using ImageView.setImageResource() or ImageView.setImageDrawable() rather than ImageView.setBackgroundDrawable().

这篇关于Android的ViewFlipper动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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