May 16 2022
, Kotlin 1.6, Android 12.0, Android Studio 2021.1.1Kotlin 1.6, Android 12.0, Android Studio 2021.1.1
Learn how to use the amazing features that come with the new Material Design 3 to create better-looking apps with a more personal feel.
By Harun Wangereka.
Similar to the Home Screen destination, you add enterTransition and exitTransition, but in opposite directions.
Your app is now ready to use these transitions while moving from one destination to another. You only need to use the NavController from Accompanist.
Head to presentation/screens/HomeActivityScreen.kt and replace val navController = rememberNavController() with:
val navController = rememberAnimatedNavController()
Resolve the import error by pressing Option-Enter on Mac or Alt-Enter on Windows PC. The code above creates a NavHostController that supports navigation animations that aren’t yet supported by the Compose Navigation library.
Well done!
Build and run your app. Tap Create and fill in the event details. After that, you should be able to see all the various transitions you’ve added and the animations too:
Note: At the time of writing, Material Design 3 and other APIs used in this tutorial are experimental and could change at any time. All the APIs are marked with the @ExperimentalAnimationApi annotation.
Where to Go From Here?
Download the final project by clicking Download Materials at the top or bottom of the tutorial.
Congratulations on learning Material Design 3, how to apply dynamic colors to your apps, and how to use Material Motion to enrich the user experience for your app!
To find out more about Material Design 3, follow this link.
You can do a lot in terms of adding animations. Since you now have the basics to get you started, you can explore how to add more animations and personalization to your app. To learn more about Jetpack Compose Animations, check out the official documentation.
Hopefully, you enjoyed this tutorial. If you have any questions or comments, please join the forum discussion below!
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.