here I am use this code for make scale animation
Animation anim = new ScaleAnimation(1f, 0f, 1f, 0f, b, a);
anim.setDuration(130);
anim.setFillAfter(false);
view.startAnimation(anim);
anim.start();
now my view animation without problem but when i add another animation to it its didn't animate any one and this is my code for make two animation its scale and translate
Animation anim = new ScaleAnimation(1f, 0f, 1f, 0f, b, a);
Animation animT = new TranslateAnimation(0f,b,0f,a);
anim.setDuration(130);
animT.setDuration(130);
anim.setFillAfter(false);
animT.setFillAfter(false);
view.startAnimation(anim);
view.startAnimation(animT);
anim.start();
animT.start();
as we can see i cant use both of the animation as same time how can i solve it without use xml animataion because my variable was changed every time
In Android, ViewAnimator is a sub class of FrameLayout container that is used for switching between views. It is an element of transition widget which helps us to add transitions on the views ( like TextView, ImageView or any layout). It is mainly useful to animate the views on screen.
To start the animation we need to call the startAnimation() function on the UI element as shown in the snippet below: sampleTextView. startAnimation(animation); Here we perform the animation on a textview component by passing the type of Animation as the parameter.
Android's transition framework allows you to animate all kinds of motion in your UI by simply providing the starting layout and the ending layout.
Use AnimationSet
as follows:
AnimationSet set = new AnimationSet(true);
Animation anim = new ScaleAnimation(1f, 0f, 1f, 0f, b, a);
Animation animT = new TranslateAnimation(0f, b, 0f, a);
set.addAnimation(anim);
set.addAnimation(animT);
set.setDuration(130);
view.startAnimation(set);
you need to use AnimationSet
and add whatever animation type you want to it
here is an example
Animation fadeIn = new AlphaAnimation(0, 1);
fadeIn.setDuration(1000);
Animation fadeOut = new AlphaAnimation(1, 0);
fadeOut.setStartOffset(1000);
fadeOut.setDuration(1000);
AnimationSet animation = new AnimationSet(true);
animation.addAnimation(fadeIn);
animation.addAnimation(fadeOut);
view.startAnimation(animation);
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