How to create android wipe transition between two

2019-03-26 14:41发布

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

3条回答
在下西门庆
2楼-- · 2019-03-26 15:03

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();
查看更多
Deceive 欺骗
3楼-- · 2019-03-26 15:03
    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android">
        <translate
            android:duration="700"
            android:fromXDelta="90%"
            android:toXDelta="0" />
    </set>


<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="700"
        android:fromXDelta="5"
        android:toXDelta="100%" />
</set>
查看更多
手持菜刀,她持情操
4楼-- · 2019-03-26 15:25

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>
查看更多
登录 后发表回答