Animated transition between activity and other

I declare that I am not very experienced in Android, and I would like to understand, perhaps with the help of some tutorial, how to implement any scroll animation between one action and another. I hope for your help.

+8
android android-layout android-intent android-widget
source share
1 answer

You can customize the animation (for example, a slide) when switching between such actions:

In the res folder, create an anim folder

For example, put two xml files for the slide effect:

slide_in.xml

 <set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false"> <translate android:fromXDelta="100%" android:toXDelta="0%" android:fromYDelta="0%" android:toYDelta="0%" android:duration="200"/> </set> 

slide_out.xml

 <set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false"> <translate android:fromXDelta="100%" android:toXDelta="0%" android:fromYDelta="0%" android:toYDelta="0%" android:duration="200" /> </set> 

Then in your java code just write this:

 Intent i = new Intent(YourActivity.this, OtherActivity.class); this.startActivity(i); overridePendingTransition(R.anim.slide_in, R.anim.slide_out); 

If you are testing this on a real device, do not forget to allow it to play animations (Settings β†’ Display β†’ Animation β†’ All animations)

Hope this helps! :)

+25
source share

All Articles