Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create android wipe transition between two layout

I am trying to create a transition animation in an Android application to change between two layouts. I've tried to search about animation transition, but only fade transition, slide transition, bounce, etc. I can't find one for wipe transition like transition at power point.

enter image description here

like image 642
user3410051 Avatar asked Mar 14 '14 11:03

user3410051


2 Answers

in your activity execute the animation with the following:

This will do a top to bottom to top animation that you can easily manipulate to be horizontal. startActivityForResult(i,ACTIVITY_SLIDE);
overridePendingTransition(R.anim.bottom_in, R.anim.top_out);

top_out.xml, bottom_in.xml below... need to be separate files of course

<?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/linear_interpolator">
        <translate
            android:fromYDelta="100%p"
            android:toYDelta="0"
            android:duration="3000"/>
    </set>




<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator">
    <translate
        android:fromYDelta="0"
        android:toYDelta="-100%p"
        android:duration="3000"/>
</set>
like image 127
user2658370 Avatar answered Oct 11 '22 03:10

user2658370


Use ClipBound Property of view

Rect localRect = view.getVisibileRect();// or you can assign any required rectangle.

Rect rectFrom,rectTo;

Rect rectFrom = new Rect(localRect),rectTo = new Rect(localRect);

now adjust your both starting and ending rectangle according to requirement.

Animator animator = ObjectAnimator.ofObject(shape, "clipBounds", new RectEvaluator(), rectFrom, rectTo);

animator.start();
like image 41
CodeWithVikas Avatar answered Oct 11 '22 03:10

CodeWithVikas