Android development – Custom Animation

Android developers web site provide you with 2 predefined animation techniques which you can use in your applications – Tween animation and frame animation. They are super easy to implement and work quite nice. If you are using Android 3.0 or above, you should check out Property Animation technicqe. But what if you need to create your own customized animations and you are using older versions? Don’t worry, that is easy to do as well, here is how you do it. To create a customized animation you need to follow these 3 steps. For the explanation, we will create a simple animation that changes the background of a button gradually from black to red. Step 1 – Extend the Animation class and set the properties Create a class which extends Android Animation class. This class will hold the logic of your animation. See my example: As you see, there is not much in this class since my animation is not that complicated. Notice that I have made all the necessary animation parameters initialization from inside the constructor, but you can defiantly initialize them from outside the class. There are 2 important parameters which determines the behavior of the animation: RepeatCount Continue reading Android development – Custom Animation