Text Clock in Android using Jetpack Compose Last Updated : 20 Mar, 2025 Comments Improve Suggest changes Like Article Like Report Text Clock is a UI widget in android which is used to display the current time in android applications. This widget displays the current time in a simple text view. The text clock widget displays a time in 12 and 24 hours format. In this article, we will take a look at How to use the TextClock widget on android using Jetpack Compose. Step by Step ImplementationStep 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.Step 2: Working with the MainActivity.kt fileGo to the MainActivity.kt file and refer to the following code. Comments are added inside the code to understand the code in more detail.In this file, we will be using the AndroidView composable to integrate the xml view, TextClock in compose.MainActivity,kt: Kotlin package com.geeksforgeeks.demo import android.os.Bundle import android.widget.TextClock import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.foundation.layout.* import androidx.compose.runtime.* import androidx.compose.ui.* import androidx.compose.ui.unit.* import androidx.compose.ui.viewinterop.AndroidView import androidx.core.content.ContextCompat import com.geeksforgeeks.demo.ui.theme.DemoTheme class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { DemoTheme { DisplayTextClock() } } } } @Composable fun DisplayTextClock() { Column( modifier = Modifier.fillMaxSize(), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center ) { // Android view composable to use xml views in compose AndroidView( factory = { context -> // Text Clock TextClock(context).apply { // set hour format format12Hour = "hh:mm:ss a" // set time zone timeZone = timeZone // set text size textSize= 32f // set text color setTextColor(ContextCompat.getColor(context, R.color.black)) } }, modifier = Modifier.padding(5.dp), ) } } Output: Comment More infoAdvertise with us Next Article Text Clock in Android using Jetpack Compose C chaitanyamunje Follow Improve Article Tags : Kotlin Android Android-Jetpack Similar Reads Text in Android using Jetpack Compose Jetpack Compose is a new toolkit provided by Google. This is useful for designing beautiful UI designs. Android Text is a simple view in Android which is used to display text inside our App. In this article, we will take a look at the implementation of Text in Android using Jetpack Compose. Importan 5 min read Curved Text in Android using Jetpack Compose In Android, there are no inbuilt schemes to implement designed text like the word art, which is available in applications like MS Word. We can always refer to or download such schemes like designed font faces to implement designed text. However, it is also possible to natively build (building from s 3 min read Button in Android using Jetpack Compose Jetpack Compose is a new toolkit provided by Google. This is useful for designing beautiful UI designs. A Button is a UI component in Android which is used to navigate between different screens. With the help of a button, the user can interact with your app and perform multiple actions inside your a 3 min read ListView in Android using Jetpack Compose A ListView is a UI component that displays data in a vertically scrollable list, where each item is placed one below the other. It is widely used in Android applications to showcase categorized data in an organized manner. In Jetpack Compose, the traditional ListView from XML-based layouts is replac 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 Like