Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to animate a view in Android and have it stay in the new position/size?

I currently have a view in my Android app and the view is playing a frame animation. I want to animate the view to increase its size to 150%. When I apply a scale animation to it, and the scale animation is completed, I want the viewer to stay at that new size for the rest of the activity's life cycle. Unfortunately right now when the scale-up animation is complete, the view snaps back to the original size. How can I get it to keep the new animated transformation?

I'm using

myView.startAnimation(AnimationUtils.loadAnimation(mContext,R.anim.scaleUp150)); 

Thanks!

like image 746
justinl Avatar asked Jul 27 '10 15:07

justinl


People also ask

What are the two different types of view animations in Android?

The animations are basically of three types as follows: Property Animation. View Animation. Drawable Animation.

How do I change an animation layout?

All you need to do is set an attribute in the layout to tell the Android system to animate these layout changes, and system-default animations are carried out for you. Tip: If you want to supply custom layout animations, create a LayoutTransition object and supply it to the layout with the setLayoutTransition() method.


1 Answers

Make sure you add below attributes to the root element in your animation xml:

android:fillAfter="true"  android:fillEnabled="true" 
like image 165
Qlimax Avatar answered Oct 20 '22 16:10

Qlimax