0

I have written an xml that works well to move an activity from right to left on click. But now what exactly I want is to convert that xml in code that will move an activity from bottom to top on click.

Here is my xml for right to left

right1.xml

<?xml version="1.0" encoding="utf-8"?>
<set
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    android:fillAfter="true">

   <translate
        android:fromXDelta="-100%p"
        android:toXDelta="0%p"
        android:duration="200" />
</set>

And here is another xml right2.xml

<?xml version="1.0" encoding="utf-8"?>
<set
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    android:fillAfter="true">

   <translate
        android:fromXDelta="0%p"
        android:toXDelta="100%p"
        android:duration="200" />
</set>

And here I used this code for switching between activities

Intent intent = new Intent(Activity1.this, Activity2.class);

startActivity(intent);
                    Activity1.this.overridePendingTransition(R.anim.right1, R.anim.right2);

Now I want it to change to bottom top move, that is to move activity from bottom to top. Any help will be highly appreciated. Thanks in advance.

Abid Khan
  • 2,451
  • 4
  • 22
  • 45

3 Answers3

0

Check this if you are looking for Top-Bottom and Bottom-Up animations :

Android Animation Example

You can change the value of fromDelta and toDelta if you want from left-right and right-left animations.

Hope this helps.

Community
  • 1
  • 1
Siddharth_Vyas
  • 9,972
  • 10
  • 39
  • 69
0

push_up_in.xml

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

push_up_out.xml

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

For changing activity :

Intent nextActivity = new Intent(getApplicationContext(),
                nextactivity.class);
startActivity(nextActivity);
overridePendingTransition( R.anim.slide_up_in, R.anim.slide_up_out );
Nikita G.
  • 720
  • 1
  • 14
  • 22
Android
  • 8,995
  • 9
  • 67
  • 108
0

For bottom to Top animation use this:

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

you can specify the duration that you want to implement in mili seconds.

Kishan Dhamat
  • 3,746
  • 2
  • 26
  • 36