4- Android Animations in Kotlin
4- Android Animations in Kotlin
Table of Attributes :
At first, we will create a new android application. Then, we will create some
animations.
If you already created the project then ignore step 1.
XML
After modifying the layout we will create xml files for animations. so we will
first create a folder name anim.
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.
bounce.xml
In this animation the text is bounce like a ball.
XML
fade_in.xml
XML
fade_out.xml
In Fade Out animation the colour of text is faded for a particular amount of
time.
XML
rotate.xml
XML
slide_down.xml
XML
slide_up.xml
XML
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="1000"
android:fromYDelta="0"
android:toYDelta="-100%" />
</set>
zoom_in.xml
In this animation the text will appear bigger for a particular amount of time.
XML
zoom_out.xml
In this animation the text will appear smaller for a particular amount of time.
XML
Open app/src/main/java/net.geeksforgeeks.AnimationsInKotlin/MainActivity.kt
file and add below code into it.
Kotlin
package net.geeksforgeeks.animationsinkotlin
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.view.View
import android.view.animation.AnimationUtils
import kotlinx.android.synthetic.main.activity_main.*
AndroidManifest.xml file
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</manifest>
Run as Emulator:
00:00 00:20
Similar Reads
Android Rotate animations in How to make Check/Tick and
Kotlin Cross animations in Android
Related Tutorials
Spring MVC Tutorial Spring Boot Tutorial
Previous Next
Commerce UPSC
Accountancy Polity Notes
Business Studies Geography Notes
Economics History Notes
Management Science and Technology Notes
Income Tax Economics Notes
Finance Important Topics in Ethics
Statistics for Economics UPSC Previous Year Papers