Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android animation to shrink and fade out a View at the same time

I can do the fade out. But not the shrink. I want it to look like it's going into the distance far, far away.

I want an animation similar to the one used in www.screamintothevoid.com

like image 425
Adarsh ML Avatar asked Oct 07 '15 12:10

Adarsh ML


2 Answers

That should work like you want it.

animation.xml in /res/anim

 <set xmlns:android="http://schemas.android.com/apk/res/android">
        <scale xmlns:android="http://schemas.android.com/apk/res/android"
            android:fromXScale="1"
            android:toXScale="0"
            android:fromYScale="1"
            android:toYScale="0"
            android:duration="5000"
            android:pivotX="50%"
            android:pivotY="50%" >
        </scale>

        <alpha
            android:fromAlpha="1"
            android:toAlpha="0"
            android:duration="5000" >
        </alpha>
    </set>

to call this animation:

TextView textView = (TextView) findViewById(R.id.text_view);
Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.animation);
textView.startAnimation(animation);
like image 99
Surro Avatar answered Nov 04 '22 01:11

Surro


To shrink a view change its scale values, for example:

TextView textToShrink = (TextView) findViewById(R.id.text_to_shrink);
textToShrink.animate().scaleX(0.3f).scaleY(0.3f).setDuration(600).start();
like image 29
Vitaly Zinchenko Avatar answered Nov 03 '22 23:11

Vitaly Zinchenko