androidandroid-layoutandroid-activityandroid-animationslideup

slide up xml animation on change activity in android


I read the below link before posting this.

How to apply slide animation between two activities in Android?

I need to know how to make activity slideup xml animation. like what they have done for fadein and fadeout.


Solution

  • for slide_in xml :

    <translate 
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:duration="250" 
          android:fromXDelta="-100%p" 
          android:toXDelta="0%p">
    </translate>
    

    for slide_out xml:

    <translate
          xmlns:android="http://schemas.android.com/apk/res/android" 
          android:duration="200" 
          android:fromXDelta="0" 
          android:toXDelta="100%p">
    </translate>
    

    Java code :

    Intent intent = new Intent(this, newActivity.class);
    startActivity(intent);
    overridePendingTransition(R.anim.slide_in, R.anim.slide_out);
    

    put both xml files in res/anim folder.