android 活动垂直过渡动画
android activities vertical transition animation
我不知道这里出了什么问题。试图在两个活动之间制作垂直动画。 Activity 1 应该从可见滑到底部。 Activity 2 应该从上到下滑动(变得可见)。
这就是我想要的
我的代码
overridePendingTransition(R.anim.top_to_visible, R.anim.visible_to_bottom);
top_to_visible.xml
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromYDelta="100%p" android:toYDelta="0%p"
android:duration="300"/>
visible_to_bottom.xml
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromYDelta="0%p" android:toYDelta="-100%p"
android:duration="300"/>
这里有什么问题吗?
试试这个 visible_to_bottom.xml 动画 ..
android:fromYDelta="0%p" android:toYDelta="100%p"
去掉负号“-100%p”->“100%p”
您将需要使用 anim
。先创建两个xml文件,放入res/anim
top_to_visible.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromYDelta="-100%p"
android:toYDelta="0" />
visible_to_bottom.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromYDelta="0%p"
android:toYDelta="100%p" />
难不成你以为y轴原点在底部?因为当我只修改 from/to 值时,我得到了你想要的。 y 的 0% 在顶部。 0/0 点位于左上角。因此,基于此,您需要 "to bottom" 从 0 移动到 100%,而 "from top to visible" 是 -100% 到 0%
top_to_visible.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:fromYDelta="-100%p"
android:interpolator="@android:anim/accelerate_interpolator"
android:toYDelta="0%p" />
</set>
和visible_to_bottom
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:fromYDelta="0%p"
android:interpolator="@android:anim/accelerate_interpolator"
android:toYDelta="100%p" />
</set>
我不知道这里出了什么问题。试图在两个活动之间制作垂直动画。 Activity 1 应该从可见滑到底部。 Activity 2 应该从上到下滑动(变得可见)。
这就是我想要的
我的代码
overridePendingTransition(R.anim.top_to_visible, R.anim.visible_to_bottom);
top_to_visible.xml
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromYDelta="100%p" android:toYDelta="0%p"
android:duration="300"/>
visible_to_bottom.xml
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromYDelta="0%p" android:toYDelta="-100%p"
android:duration="300"/>
这里有什么问题吗?
试试这个 visible_to_bottom.xml 动画 ..
android:fromYDelta="0%p" android:toYDelta="100%p"
去掉负号“-100%p”->“100%p”
您将需要使用 anim
。先创建两个xml文件,放入res/anim
top_to_visible.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromYDelta="-100%p"
android:toYDelta="0" />
visible_to_bottom.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromYDelta="0%p"
android:toYDelta="100%p" />
难不成你以为y轴原点在底部?因为当我只修改 from/to 值时,我得到了你想要的。 y 的 0% 在顶部。 0/0 点位于左上角。因此,基于此,您需要 "to bottom" 从 0 移动到 100%,而 "from top to visible" 是 -100% 到 0%
top_to_visible.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:fromYDelta="-100%p"
android:interpolator="@android:anim/accelerate_interpolator"
android:toYDelta="0%p" />
</set>
和visible_to_bottom
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:fromYDelta="0%p"
android:interpolator="@android:anim/accelerate_interpolator"
android:toYDelta="100%p" />
</set>