How to make Zoom in animation in Android Studio

Hello Guys, Lets see how to make Zoom Animation in android:

ZoomIn Animation






Step 1: Create a anim folder in res. Also create a file in anim folder named zoomin. If you don't know how to creat anim folder and files in it. Just visit here to learn.

Create animation Folder and file



2. zoomin.xml


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale
        android:fromXScale="0"
        android:toXScale="1"
        android:fromYScale="0"
        android:toYScale="1"
        android:pivotX="50%"
        android:pivotY="50%"
        android:fillAfter="false"
        android:duration="2000"/>
</set>

  •   The pivotX and pivotY is the central point of the animation.
  • android:pivotX="50%" and android:pivotY="50%" will mean the zoom will be started from the center.





3.activity_main.xml
----- put an Image in your xml file with ImageView.


1
2
3
4
5
   <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/iv"
        android:src="@drawable/ss2"/>



3. MainActivity.java
             Write this code in onCreate method


ImageView iv=(ImageView)findViewById(R.id.iv);
Animation anim=AnimationUtils.loadAnimation(MainActivity.this, R.anim.zoomin);
iv.setAnimation(anim);




Comments

  1. This comment has been removed by the author.

    ReplyDelete
  2. Do you mind if I quote a couple of your posts as long as I provide credit and sources back to your blog? My blog is in the same niche as yours, and my users would benefit from some of the information you provide here. Please let me know if this ok with you. Thank you.
    Surya Informatics

    ReplyDelete

Post a Comment