Home > other >  How to slide page out left at Android
How to slide page out left at Android

Time:10-29

Want to do

When I transition the page(Activity), I want to add animation like slide out left.

I tried these codes for animation. These have SlideInLeft and SlideOutRight but don't have SlideOutLeft.

Bundle animationBundle = ActivityOptions.MakeCustomAnimation(this, Resource.Animation.abc_fade_in, Resource.Animation.abc_fade_out).ToBundle();

and

This.OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight);

CodePudding user response:

You can try to create a folder named anim below the Resources folder, and then create a slide_out_left.xml in it, such as:

<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="0" android:toXDelta="-50%p"
    android:duration="@android:integer/config_mediumAnimTime"/>
<alpha android:fromAlpha="1.0" android:toAlpha="0.0"
    android:duration="@android:integer/config_mediumAnimTime" />
</set>

And then use it in the This.OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Resource.Animation.slide_out_left);

For more information, you can refer to this case and this one.

  • Related