Animating Circle Drawing in Android using Jetpack Compose Last Updated : 05 Mar, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report In Android, we can create animations of our choice for displaying an entry, in-transit, or exit of an element or a view. The most commonly inbuilt animation is of Circular ProgressBar, where an animator sweeps out a circle indicating the progress of the executed task. A sample video is given below to get an idea about what we are going to do in this article. In this article, we will show you how you could create such an animation in Android using Jetpack Compose.Steps to Implement in Animating Circle DrawingStep 1: Create a New Project in Android StudioTo 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 the MainActivity.kt fileGo to the MainActivity.kt file and refer to the following code. Below is the code for the MainActivity.kt file. Comments are added inside the code to understand the code in more detail.MainActivity.kt: Kotlin package com.geeksforgeeks.demo import android.os.Bundle import androidx.activity.* import androidx.activity.compose.setContent import androidx.compose.animation.core.* import androidx.compose.foundation.Canvas import androidx.compose.foundation.layout.* import androidx.compose.runtime.* import androidx.compose.ui.* import androidx.compose.ui.geometry.Size import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.drawscope.Stroke import androidx.compose.ui.unit.dp import com.geeksforgeeks.demo.ui.theme.DemoTheme class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) enableEdgeToEdge() setContent { DemoTheme(dynamicColor = false, darkTheme = false) { Column( Modifier.fillMaxSize(), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center ) { CircleAnimation() } } } } } @Composable fun CircleAnimation(modifier: Modifier = Modifier) { // Declaring circle radius val radius = 200f // Creating animation val animateFloat = remember { Animatable(0f) } LaunchedEffect(animateFloat) { animateFloat.animateTo( targetValue = 1f, animationSpec = tween( durationMillis = 3000, easing = LinearEasing ) ) } // Creating Arc with useCenter as True Row { Canvas( modifier = Modifier .width(100.dp) .height(100.dp) ) { drawArc( color = Color.Black, startAngle = 0f, sweepAngle = 360f * animateFloat.value, useCenter = true, size = Size(radius * 2, radius * 2), style = Stroke(2.0f) ) } } // Adding a Space of height 100dp Spacer(modifier = Modifier.height(100.dp)) // Creating Arc with useCenter as False Row { Canvas( modifier = Modifier .width(100.dp) .height(100.dp) ) { drawArc( color = Color.Black, startAngle = 0f, sweepAngle = 360f * animateFloat.value, useCenter = false, size = Size(radius * 2, radius * 2), style = Stroke(2.0f) ) } } } Output: Comment More infoAdvertise with us A aashaypawar Follow Improve Article Tags : Kotlin Android-Jetpack Similar Reads Kotlin Tutorial This Kotlin tutorial is designed for beginners as well as professional, which covers basic and advanced concepts of Kotlin programming language. In this Kotlin tutorial, you'll learn various important Kotlin topics, including data types, control flow, functions, object-oriented programming, collecti 4 min read Kotlin Android Tutorial Kotlin is a cross-platform programming language that may be used as an alternative to Java for Android App Development. Kotlin is an easy language so that you can create powerful applications immediately. Kotlin is much simpler for beginners to try as compared to Java, and this Kotlin Android Tutori 6 min read Android Jetpack Compose Tutorial Android Jetpack Compose Tutorial encompasses both fundamental and advanced topics will help elevate from beginner to expert, this tutorial allows newcomers to follow a sequential path to master the basics of Android development.In this Android Jetpack Compose Tutorial, you'll explore a new and excit 5 min read Basics of Jetpack Compose in Android Jetpack Compose is a modern UI toolkit that is designed to simplify UI development in Android. It consists of a reactive programming model with conciseness and ease of Kotlin programming language. It is fully declarative so that you can describe your UI by calling some series of functions that will 5 min read Retrofit with Kotlin Coroutine in Android Retrofit is a type-safe http client which is used to retrieve, update and delete the data from web services. Nowadays retrofit library is popular among the developers to use the API key. The Kotlin team defines coroutines as âlightweight threadsâ. They are sort of tasks that the actual threads can e 3 min read Introduction to Kotlin Kotlin is a statically typed, general-purpose programming language developed by JetBrains, which has built world-class IDEs like IntelliJ IDEA, PhpStorm, Appcode, etc. It was first introduced by JetBrains in 2011 as a new language for the JVM. Kotlin is an object-oriented language, and a better lang 4 min read Kotlin Data Types The most fundamental data type in Kotlin is the Primitive data type and all others are reference types like array and string. Java needs to use wrappers (java.lang.Integer) for primitive data types to behave like objects but Kotlin already has all data types as objects.There are different data types 3 min read Kotlin when expression In Kotlin, when replaces the switch operator of other languages like Java. A certain block of code needs to be executed when some condition is fulfilled. The argument of when expression compares with all the branches one by one until some match is found. After the first match is found, it reaches to 6 min read Kotlin Constructor A constructor is a special member function that is automatically called when an object of a class is created. Its main purpose is to initialize properties or perform setup operations. In Kotlin, constructors are concise, expressive, and provide significant flexibility with features like default para 6 min read Android RecyclerView in Kotlin In this article, you will know how to implement RecyclerView in Android using Kotlin . Before moving further let us know about RecyclerView. A RecyclerView is an advanced version of ListView with improved performance. When you have a long list of items to show you can use RecyclerView. It has the ab 4 min read Like