0

I want my image to animate by a click such as it should first zoom-out and then zoom-in in a fraction of second, while the zoom-in action takes place the image should disappear. How to perform the action.

  • Welcome to Stackoverflow. Please show your code for proving how far did you try and help others members to understand your problem better while you will be providing a context of your issue. https://stackoverflow.com/help/how-to-ask – Kenzo_Gilead Apr 27 '17 at 06:55

1 Answers1

1

Create a anim folder in your res directory of project

and create a anim xml inside that

   <set xmlns:android="http://schemas.android.com/apk/res/android"
        android:fillAfter="true" >


        <!--  zoom in animation      -->
        <scale
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:duration="100"
            android:fromXScale="1"
            android:fromYScale="1"
            android:pivotX="50%"
            android:pivotY="50%"
            android:toXScale="3"
            android:toYScale="3" >
        </scale>

 <!--  zoom out animation      -->
    <scale xmlns:android="http://schemas.android.com/apk/res/android">
        android:duration="200"
        android:fromXScale="1.0"
        android:fromYScale="1.0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="0.5"
        android:toYScale="0.5" >
    </scale>
    </set>

you can use in different xmls and call them with handler or you can use them like this

in Activity where you need to call this globbaly

Animation zoomoutandzoomin;

and inside oncreate zoomoutandfade=

AnimationUtils.loadAnimation(Splash.this,R.anim.fade_zoomoutandin);

on button click

ivpawfour.startAnimation(zoomoutandzoomin);

or find this thread [Android imageView Zoom-in and Zoom-Out

Community
  • 1
  • 1
ajay.kumar
  • 173
  • 1
  • 5