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);
I'm not sure if I'm even on the right track using a viewFlipper so any help would be greatly appreciated!
Cheers
android.widget.ViewFlipper. Simple ViewAnimator that will animate between two or more views that have been added to it. Only one child is shown at a time. If requested, can automatically flip between each child at a regular interval.
In Android Animations are the visuals that are added to make the user interface more interactive, clear and good looking. Fade In and Fade out animations are used to modify the appearance of any view over a set interval of time so that user can be notified about the changes that are occurring in our application.
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.
Also, you should be using ImageView.setImageResource()
or ImageView.setImageDrawable()
rather than ImageView.setBackgroundDrawable()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With