3

In MVVMCross is easy to develop Activity transitions, but i'm finding so many troubles trying to develop this with fragments.

I got an application with a Hamburger Menu, and I wanna be capable to edit my own transitions between fragments. I've been searching in the internet but i cant find any solution.

Thank you for your attention.

jzeferino
  • 7,700
  • 1
  • 39
  • 59
JCQuiroga
  • 33
  • 4

1 Answers1

8

If you are using MvxCachingFragmentCompatActivityas the base type for your activity you can override OnBeforeFragmentChanging method to set a custom transition animation.

public override void OnBeforeFragmentChanging(
    IMvxCachedFragmentInfo fragmentInfo, 
    Android.Support.V4.App.FragmentTransaction transaction)
{
    transaction.SetCustomAnimations(
        // Your entrance animation xml reference
        Resource.Animation.slide_in_from_right,
        // Your exit animation xml reference
        Resource.Animation.slide_out_to_left);

    base.OnBeforeFragmentChanging(fragmentInfo, transaction);
}
Plac3Hold3r
  • 5,062
  • 1
  • 16
  • 21
  • 3
    A quick note: To animate in reverse when fragments are popped from the stack, add 3rd and 4th arguments to `SetCustomAnimations` for `popEnter` and `popExit`, as in: `transaction.SetCustomAnimations( Resource.Animation.slide_in_from_right, Resource.Animation.slide_out_to_left, Resource.Animation.slide_in_from_left, Resource.Animation.slide_out_to_right);` – Luke Pothier Oct 15 '16 at 11:54