O'Reilly logo

Xamarin Mobile Development for Android Cookbook by Matthew Leibowitz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Animating fragment navigation

Navigating between fragments is easy to do, but it appears very sharp and does not provide a smooth user experience. We can improve this by adding transitions to the navigation.

How to do it...

When navigating between fragments, we can add an animation, or rather a transition to make the overall change seem less sharp and more appealing:

  1. One of the simplest ways to add animations to transitions is to simply make use of the built-in animations, such as fade or open. This is set by calling the SetTransition() method:
    SupportFragmentManager
      .BeginTransaction()
      .SetTransition(FragmentTransaction.TransitFragmentOpen)
      .Replace(Resource.Id.fragmentContainer, content)
      .AddToBackStack(null)
      .Commit();

In order to create more fragment ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required