How to Implement fade in/out Animation on a Text using Jetpack Compose Last Updated : 04 Mar, 2025 Comments Improve Suggest changes Like Article Like Report Jetpack Compose is a modern toolkit for building native Android UIs in the Android Development process, by using Jetpack Compose we can implement or create so many types of animations in Android easily. On texts using jetpack compose we can also implement multiple kinds of animations, One animation we can implement on a text is text fade in/out animation.What is Text fade in/out animation?Text fade-in/out animation refers to the process of appearance or disappearance of a text on the mobile screen, text fade-in/out animation can enhance the user experience by adding visual appeal and guiding the user's attention to the specific line or paragraph.In this post we will explain how to implement fade-in/out animation on a Text using Jetpack Compose in an Android project.Step by Step Implementation To implement the Text fade in/out Animation using Jetpack compose in Android follow these steps:Step 1 : Create a New ProjectTo create a new project in the Android Studio, please refer to How to Create a new Project in Android Studio with Jetpack Compose.Note: Select Kotlin as the programming language.Step 2 : Working with MainActivity.kt fileCreate a new composable TextFadeAnimation and call the method in MainActivity.kt file to display text fade in/out animation.MainActivity.kt: MainActivity.kt package com.geeksforgeeks.demo import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.animation.* import androidx.compose.animation.core.tween import androidx.compose.foundation.layout.* import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.* import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.* import com.geeksforgeeks.demo.ui.theme.DemoTheme import kotlinx.coroutines.* class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { DemoTheme(dynamicColor = false, darkTheme = false) { Surface( modifier = Modifier.fillMaxSize(), color = Color.White ) { TextFadeAnimation() } } } } } @Composable fun TextFadeAnimation() { var visibility by remember { mutableStateOf(true) } val coroutineScope = rememberCoroutineScope() LaunchedEffect(Unit) { coroutineScope.launch { while (true) { // Toggle visibility visibility = !visibility // Delay to control the toggle frequency delay(2000) // Adjust delay as needed } } } Box( contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize() ) { AnimatedVisibility( visible = visibility, enter = fadeIn(animationSpec = tween(durationMillis = 1100)), exit = fadeOut(animationSpec = tween(durationMillis = 1100)) ) { // Message text Text(text = "Hello, GeeksForGeeks!", fontSize = 24.sp) } } } Output: Comment More infoAdvertise with us Next Article How to Implement fade in/out Animation on a Text using Jetpack Compose A ajaykumar2pn3z Follow Improve Article Tags : Kotlin Android Android-Jetpack Android-Animation Similar Reads How to Create Outlined Text in Android using Jetpack Compose? In Android, we can customize various aspects of a Text for displaying them accordingly. We can change the font size, and font family as well as apply various functions like bold, italics, etc. However, it is not possible to display an outline font for the same text. In case, you are unaware of what 3 min read How to Create Superscript and Subscript Text using Jetpack Compose in Android? In this article, we will explain how to create a Superscript and Subscript text using Jetpack Compose. Below is the sample picture to show what we are going to build. Note that we are going to implement this project using the Kotlin language. Prerequisites: Basic Knowledge of Kotlin.Jetpack Compose 2 min read How to make Text Selectable in Android using Jetpack Compose? By default, Composable Texts are not selectable which means users cannot copy text from your application, and to enable text selection you need to wrap the text elements into Selection Container. In this article, we will use Androidâs Jetpack Compose to create those chips. A sample image is given be 2 min read Expandable Text in Android using Jetpack Compose Many applications display tons of textual data in the form of passages and have the feature of expanding or contracting it. Generally, 2-3 out of n lines of a passage are displayed along with "View More", "Read More", and "..." at the end. These appear like hyperlinks that upon click expand the text 2 min read Shimmer Animation in Android using Jetpack Compose Shimmer Animation was created by Facebook to show the loading screen while images are fetched from the server. Now we see shimmer animation in lots of places. In this article, we will take a look at the implementation of shimmer animation using the all-new Jetpack Compose. A sample GIF is given belo 3 min read Like