Enliven content material visibility
The very first thing we’ll do is add some visibility updates to our content material, ensuring it does not simply pop up within the UI with out notification. Fortunately, reaching this in Compose is easy.
First, let’s extract the content material displayed on our Cryptocurrency Card Platform:
With this extract, we will simply see how the background will be pieced collectively and the content material above it now:
Now that we have cleaned up our implementation, let’s discover how one can animate the visibility of our content material. Jetpack Compose presents us AnimationVisibility Compositable, permitting us to encompass the aspect we wish to animate and customise its visibility in line with our wants.
Do it! In accordance with the diagram on the high of the web page, our desired animation for this explicit state of affairs entails animating the looks and disappearance of content material in our structure. It matches completely with what we wish to obtain.
However nothing occurred…
The idea behind utilizing AnimatedVisibility is an replace triggered by one thing. It could possibly be a click on or an occasion in our app. Nonetheless, on this explicit case, we wish the animation to occur solely as soon as when the UI is rendered. To realize this we have to replace the seen mutable boolean utilizing LaunchEffect, which can delay this motion for a brief 300 ms:
So the content material seems with the animation fired 300 milliseconds after loading the display. Nice! Nonetheless, we wish it to look from the underside and have a fade impact. To do that, we will use the enter parameter of AnimationVisibility composable, permitting us to create any desired animation for the interface: