我正在尝试在Android应用程序中创建一个过渡动画,以在两个布局之间进行切换。我试图搜索动画过渡,但只有淡入淡出过渡,幻灯片过渡,反弹等等。我无法找到一个用于擦除过渡,如功率点过渡。
答案 0 :(得分:1)
使用视图的ClipBound属性
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();
答案 1 :(得分:1)
使用以下内容执行动画:
这将执行从上到下的动画,您可以轻松地将其操纵为水平。
startActivityForResult(I,ACTIVITY_SLIDE);
overridePendingTransition(R.anim.bottom_in,R.anim.top_out);
top_out.xml,下面的bottom_in.xml ...当然需要是单独的文件
<?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>
答案 2 :(得分:0)
<?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>