How to Add Animation to Image in Android

Adding an Animation to Image in ImageView is still the Best way of making Splash Screen.This Animation can make Your Splash screen still more interactive.There can be various animation available for a ImageView Here i will discuss some of the Animation File and How to Add Animation to your Android Application.


1)Create a ImageView in your splash Screen



Let We Consider the Above Image.Let we add an Animation to this image.This image is actuaally placed by using ImageView.



2)Create a Folder anim under the res folder.


3)Create a Animation File as Fallows





This opens the Dialog as Below





Type the name and Press ok button.

4)Write a Animation File

4a)Blink Animation File

Copy the Below code which gives a Blink to your Image File.

<alpha
    android:fromAlpha="0.0"    android:toAlpha="1.0"    android:interpolator="@android:anim/accelerate_interpolator"    android:duration="400"    android:repeatMode="reverse"    android:repeatCount="infinite"

    ></alpha>


4b)Rotating a Image through Clockwise

<rotate
    android:fromDegrees="0"    android:toDegrees="360"    android:pivotX="50%"    android:pivotY="50%"    android:duration="5000"    >
    </rotate>

<rotate
    android:startOffset="5000"    android:fromDegrees="360"    android:toDegrees="0"    android:pivotX="50%"    android:pivotY="50%"    android:duration="5000"
    >
    </rotate>

4c)Fade Animation

<set xmlns:android="http://schemas.android.com/apk/res/android"
   android:interpolator="@android:anim/accelerate_interpolator" >
   
   <alpha
      android:fromAlpha="0"
      android:toAlpha="1" 
      android:duration="2000" >
   </alpha>
   
   <alpha
      android:startOffset="2000"
      android:fromAlpha="1"
      android:toAlpha="0" 
      android:duration="2000" >
   </alpha>   


5)Add a Animation File to the ImageView Through javeFile


write the below code in your onCreate Method.

imageView=(ImageView)findViewById(R.id.imageView);


android.view.animation.Animation animation= AnimationUtils.loadAnimation(getApplicationContext(),R.anim.blink);
imageView.startAnimation(animation);



This is the simplest way of adding the animation to your ImageView.



In Next Tutorial i will teach how to add Notification through Google FCM.


                      Thank you Friends.



































Comments

Popular posts from this blog

How to Send Notification through Firebase-Android

Splash Screen-Android