Reputation: 975
I don't know what is wrong here. Trying to make a vertical animation between two activities. Activity 1 should slide from being visible to bottom. Activity 2 should slide from top to bottom (become visible).
my code
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"/>
what's wrong here ?
Upvotes: 0
Views: 854
Reputation:
You will need to use anim
. First create two xml files and put them in 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" />
Upvotes: 0
Reputation: 57672
Is it possible that you thought the y axis origin is at the bottom? Because when I just modify the from/to values I get what you want. The 0% of y is at the top. The 0/0 point is at the top left. So based on that you need the "to bottom" to move from 0 to 100% and the "from top to visible" to be -100% to 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>
and 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>
Upvotes: 3
Reputation: 226
Try this for visible_to_bottom.xml animation ..
android:fromYDelta="0%p" android:toYDelta="100%p"
remove the negative sign "-100%p" -> "100%p"
Upvotes: 0