Updated 30 December 2017
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.
In this blog, I have just added two more Simple Animations to my collection.
my_custom_animation_horizontal_loading.xml
1 2 3 4 5 6 7 8 9 |
<?xml version="1.0" encoding="utf-8"?> <translate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="1000" android:fromXDelta="0" android:interpolator="@android:anim/linear_interpolator" android:repeatCount="infinite" android:repeatMode="restart" android:toXDelta="20" /> <!--Change duration time in which you want to complete one animation--> |
my_custom_animation_circular_loading.xml
1 2 3 4 5 6 7 8 9 10 11 12 |
<?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDegrees="0" android:toDegrees="360" android:duration="400" android:repeatCount="infinite" android:pivotX="50%" android:pivotY="50%"> </rotate> <!--Change duration time in which you want to complete one animation--> |
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.
1 2 3 |
//Change the views as per your use. my_horizontal_animating_view.startAnimation((Animation) AnimationUtils.loadAnimation(this,R.anim.horizontal_loading_animation)); my_circular_animating_view.startAnimation((Animation)AnimationUtils.loadAnimation(this, R.anim.circular_rotation)); |
“…” is animating using”my_custom_animation_horizontal_loading” animation and the image is using “my_custom_animation_circular_loading” animation in the gif below.
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.