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:
- 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 ...
Get Xamarin Mobile Development for Android Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.