Redeem Now
Read More
Read now

Animations on Android


Basically, Animation is a method in which pictures are manipulated to appear as moving images. In our use case in android, the animation is giving motion to views in order to improve user experience.

Let’s start with an example of a simple rotation animation on a view

Here, we have called the animate() function which is by default present in the View class. The above code animates the view by 360 degrees for 300 ms.

Let’s see another example of an animation where we will change the image of the view.

In the first step, we will create an animation list drawable file(rocket_thrust.xml):

Then on a button click, we are going to perform the animation:

Here, on a button click animation gets started and works till the duration mentioned in the drawable file. In the drawable file, we have set the oneshot attribute as true this will only perform the animation only for one cycle otherwise it animates till stopped.

We can also reposition a view on the screen with the help of ObjectAnimator API. The ObjectAnimator API provides an easy way to move a view in a specified time. Below is an example of the same:

This example will move the view 200 pixels horizontally from the current location in 1 second.

In this way, we can create multiple animations in the app.



. . .


Add Your Comment

Be the first to comment.

Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again