In Android Animations are the visuals that are added to make the user interface more interactive, clear and good looking.
In this article we will be discussing how to create a Slide Up/Down animation in Kotlin.
|android:duration||It is used to specify the duration of animation|
|android:fromYDelta||It is the change in Y coordinate to be applied at the start of the animation|
|android:toYDelta||It is the change in Y coordinate to be applied at the end of the animation|
|android:id||Sets unique id of the view|
First step is to create a new Project in Android Studio. For this follow these steps:
- Click on File, then New and then New Project and give name whatever you like
- Then, select Kotlin language Support and click next button.
- Select minimum SDK, whatever you need
- Select Empty activity and then click finish.
After that, we need to design our layout. For that we need to work with the XML file. Go to app > res > layout and paste the following code:
Modify activity_main.xml file
Add anim folder
In this folder, we will be adding the XML files which will be used to produce the animations. For this to happen, go to app/res right click and then select, Android Resource Directory and name it as anim.
Again right click this anim folder and select Animation resource file and name it as slide_up. Similarly, also create slide_down.xml and paste the following code.
Modify MainActivity.kt file
Open app/src/main/java/yourPackageName/MainActivity.kt and do the following changes:
Run as emulator:
- How to display bootstrap carousel with three post in each slide?
- How to Hide and show slide arrows in slick slider?
- Android EditText in Kotlin
- Android LinearLayout in Kotlin
- Android RelativeLayout in Kotlin
- Android ListView in Kotlin
- Android FrameLayout in Kotlin
- Android TableLayout in Kotlin
- Android Toast in Kotlin
- Android Fade In/Out in Kotlin
- Android Animations in Kotlin
- Android progress notifications in Kotlin
- Kotlin Android Tutorial
- Difference between Java and Kotlin in Android with Examples
- Thread Priority in Kotlin & Android
- Running User Interface Thread in Android using Kotlin
- How to Add RangeSeekbar in Android Using Kotlin?
- Android WebView in Kotlin
- How to add a custom styled Toast in Android using Kotlin
- Android Rotate animations in Kotlin
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.