Some More Simple Animations

Updated 30 December 2017

Save

In this Blog, we will learn about using some more simple animations in your android application.

For Checking what this blog is all about, please scroll to the end of the blog, there you will see a sample gif demo of animations covered in this blog.

Well, the content in this blog is in addition to my previous blog, so if you don’t get to understand something, please read this blog first.

Add Simple animations in your android application

 

In this blog, I have just added two more Simple Animations to my collection.

APPROACH :

  1. In the”res” folder of your project, create a new folder and name it “anim”.
  2. You need to create an xml file in which you will write the code for your animation.
  3.  Get the object of the view in your activity/fragment.
  4. Call the startAnimation() method on the view. This method call requires you to send an object of animation in params.
  5. You can either create a new animation object and assign it the value returned by AnimationUtils.loadAnimation()method or directly pass the AnimationUtils.loadAnimation() method in the method used in step4.
  6.  The AnimationUtils.loadAnimation() method takes two parameters: the first one is the Context, second one is the id of your xml file in which the animation is set. You need to pass the resourceId of the file you created in step2 (something like R.anim.your_file_name)

CODE:

my_custom_animation_horizontal_loading.xml

my_custom_animation_circular_loading.xml

Using these in your code.

Get an instance of the view which you want to animate and use below shared lines to apply animation to that particular view.

DEMO :

“…” is animating using”my_custom_animation_horizontal_loading” animation and the image is using “my_custom_animation_circular_loading” animation in the gif below.

author
. . .

Leave a Comment

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


Be the first to comment.

Start a Project


    Message Sent!

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

    Back to Home