Android Kotlin – Navigation and animation

You can use animation when you use Navigation. It is to implement it. First, you need to create a new animation resource file. Right-click res folder, then click New and then New Android Resource File. You will see the following window. Specify the filename and choose Animation from the Resource type drop-down list. Click OK.

, <span>Android Kotlin – Navigation and animation</span>, KandZ

Open the animation resource file and create an animation. The following is a simple fade-in animation.

<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="0.00"
android:toAlpha="1.00"
android:duration="@android:integer/config_longAnimTime"/>
</set>
, <span>Android Kotlin – Navigation and animation</span>, KandZ

Now open the navigation layout and click on an action you want to have animation.

, <span>Android Kotlin – Navigation and animation</span>, KandZ

Now at the right panel, find the Transitions. You have four available transitions. Select the animation you have created before, from the transition’s drop-down list you want. 

, <span>Android Kotlin – Navigation and animation</span>, KandZ

Now you can test the application. That was all!

41230cookie-checkAndroid Kotlin – Navigation and animationAndroid Kotlin – Navigation and animation

Related posts