Start a Project

EnterTransition in jetpack compose

In this blog, we are learning the EnterTransition in jetpack compose. Quickly bring your app to life with less code, powerful tools, and intuitive Kotlin APIs. The remaining experience is as follows so Combines different enter transitions. EnterTransition defines how an AnimatedVisibility Composable appears on screen as it becomes visible.

Dependency

Animation

We are creating an animation composble function and now that the new rememberAnimatedNavController method because the new AnimatedNavHost composable have been released. you should also have access to a new version of the composable extension function. To begin receiving the bespoke animated deliciousness, replace your outdated code with shortly. This function uses two screens to open with an animation effect.

The 4 categories of EnterTransitions available are:

  1. fade: fadeIn
  2. scale: scaleIn
  3. slide: slideInslideInHorizontallyslideInVertically
  4. expand: expandInexpandHorizontallyexpandVertically

Replace NavHost(…) with AnimatedNavHost, NavController() with rememberAnimatedNavController(), and com.google.accompanist.navigation.animation.composable with the import of Androidx.navigation.compose.composable.

The @ExperimentalAnimationApi once we are using experimental APIs; if you haven’t included it yet, your Android studio will presumably let you know.

We may access four additional arguments by using the new experimental composable(…) function: enterTransition, exitTransition, popEnterTransition, and popExitTransition hence improving your code skills.

For Example, check the full code.

Code

Preview

https://mobikul.com/wp-content/uploads/2022/07/preview-1.mp4

This preview displays the open registration and login screens.

Conclusion

In this blog, we have learned about the ‘EnterTransition’ in jetpack compose. so we have learned how to implementation of “AnimatedNavHost” and perform the action in Android. this is the easy way to create an animation in jetpack compose.

For more information regarding the compose gesture in android visit the link.

Thanks for reading this blog. You can also check other blogs from here.

Happy coding… 😊

Exit mobile version