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.

1 Answers 11

up vote 6 down vote accepted

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);
}
2 upvote
  flag
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

Not the answer you're looking for? Browse other questions tagged or ask your own question.