Check Mobile App
Read now

Animations on Android

Save

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.

 

References:

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

Great Product, Great Team, and Great Support Service. And if you want to add more features to the product, they can submit any idea that comes to your mind. They really care about their clients and we are really happy and honored to deal with Webkul.

Osama
Talk to Sales

Global

Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home