I need to make a certain view to appear/ disappear gradually, step by step and not suddenly. If I use MyView.setvisibility(View.GONE)
or MyView.setvisibility(View.VISIBLE)
everything happens suddenly. Any idea how to do this?
Thanks in advance.
Here is my code:
animFlipInNext = AnimationUtils.loadAnimation(this,
R.anim.push_left_in);
animFlipInNext.setDuration(2000);
animFlipInNext
.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
System.out.println("AnimStart- LeftIn"
+ " Will be displayed "
+ vf.getDisplayedChild());
if (vf.getCurrentView().equals(rr)) {
System.out.println("begin layout for video");
rr.addView(myVideoView);
myVideoView.setAnimation(AnimationUtils.loadAnimation(context, R.anim.fade_in));
/* myVideoView.startAnimation(new MyScaler(1.0f,
1.0f, 0.0f, 1.0f, 2500, myVideoView,
true));*/
}
}
@Override
public void onAnimationRepeat(Animation animation) {
System.out.println("AnimRepeat-LeftIn");
}
@Override
public void onAnimationEnd(Animation animation) { System.out.println("Anim end "
+ vf.getDisplayedChild());
if (vf.getCurrentView().equals(rr)) {
System.out.println("layout for videoView");
rr.removeAllViews();
vf.stopFlipping();
myVideoView.start();
}
}
});
I have an animation for a ViewFlipper. When ViewFlipper contains the rr RelativeLayout
I add video to it. I am tring to make video visible when is making the transition for rr
but it not worked.
View Animations are the simplest way to achieve this IMHO.
place this in /res/anim/fade_in.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="2200"></alpha>
</set>
Then in your Activity code in probably onResume do smth like:
someView.setAnimation(AnimationUtils.loadAnimation(context, R.anim.fade_in));
This will give you a fade in over 2.2 secs. Added an interpolater to the xml like the AccelerateDecelerateInterpolator for more natural feeling fades if you like.
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