Read More

Some More Simple Animations

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.

. . .

Comment

Add Your Comment

Be the first to comment.

css.php
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
Close