How to set Android ZooM in animation
The 1st Step :
Create an anim folder in res. Also create a file in anim folder named zoom_out. If you don't know how to creat anim folder and files in it. Just visit here to learn
ZooM out animation |
2. zoom_out.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true" > <scale xmlns:android="http://schemas.android.com/apk/res/android" android:duration="1000" android:fromXScale="1.0" android:fromYScale="1.0" android:pivotX="50%" android:pivotY="50%" android:toXScale="0" android:toYScale="0" android:repeatCount="10"> </scale> </set> |
3. activity_main.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.hp.symonapps.MainActivity" android:orientation="vertical" android:gravity="center"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/iv" android:src="@drawable/ss2"/> </LinearLayout> |
3. MainActivity.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | package com.example.hp.symonapps; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ImageView; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ImageView iv=(ImageView)findViewById(R.id.iv); //cast the iv imageView button Animation anim=AnimationUtils.loadAnimation(MainActivity.this, R.anim.zoom_out); iv.setAnimation(anim); } //onCreate end } |
If you've any question , please feel free to ask me in comment.
Thanks-
This comment has been removed by the author.
ReplyDeleteHello. This post couldn’t be written any better! Reading this post reminds me of my previous roommate. He always kept chatting about this. I will forward this page to him. Fairly certain he will have a good read. Thank you for sharing.
ReplyDeleteSurya Informatics
I want to know about zoom in plz guide me how can i edit it
ReplyDelete