How to Create Outlined Text in Android using Jetpack Compose? Last Updated : 30 Apr, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 outlined font is, look at the below image of sample outlined text: In this article, we will show you how you could create outlined text in Android using Jetpack Compose. Follow the below steps once the IDE is ready. Step by Step Implementation Step 1: Create a New Project in Android Studio To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. While choosing the template, select Empty Compose Activity. If you do not find this template, try upgrading the Android Studio to the latest version. We demonstrated the application in Kotlin, so make sure you select Kotlin as the primary language while creating a New Project. Step 2: Working with the MainActivity.kt file Go 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. Kotlin package com.geeksforgeeks.outlinedtext import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.foundation.Canvas import androidx.compose.foundation.layout.* import androidx.compose.material.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Paint import androidx.compose.ui.graphics.drawscope.drawIntoCanvas import androidx.compose.ui.graphics.nativeCanvas import androidx.compose.ui.unit.dp class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { // Creating a Simple Scaffold // Layout for the application Scaffold( // Creating a Top Bar topBar = { TopAppBar(title = { Text("GFG | Outlined Text", color = Color.White) }, backgroundColor = Color(0xff0f9d58)) }, // Creating Content content = { // Creating a Column Layout Column(Modifier.fillMaxSize(), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center) { // Create a Paint that has black stroke val textPaintStroke = Paint().asFrameworkPaint().apply { isAntiAlias = true style = android.graphics.Paint.Style.STROKE textSize = 100f color = android.graphics.Color.BLACK strokeWidth = 12f strokeMiter= 10f strokeJoin = android.graphics.Paint.Join.ROUND } // Create a Paint that has white fill val textPaint = Paint().asFrameworkPaint().apply { isAntiAlias = true style = android.graphics.Paint.Style.FILL textSize = 100f color = android.graphics.Color.WHITE } // Create a canvas, draw the black stroke and // override it with the white fill Canvas( modifier = Modifier.fillMaxSize(), onDraw = { drawIntoCanvas { it.nativeCanvas.drawText( "GeeksforGeeks", 200f, 200.dp.toPx(), textPaintStroke ) it.nativeCanvas.drawText( "GeeksforGeeks", 200f, 200.dp.toPx(), textPaint ) } } ) } } ) } } } Output: You can see that we are successfully able to create an outlined text. Comment More infoAdvertise with us Next Article How to Create Outlined Text in Android using Jetpack Compose? 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 Services in Android with Example Services in Android are a special component that facilitates an application to run in the background in order to perform long-running operation tasks. The prime aim of a service is to ensure that the application remains active in the background so that the user can operate multiple applications at t 10 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 Introduction to Activities in Android Activity class is one of the very important parts of the Android Component. Any app, don't matter how small it is (in terms of code and scalability), has at least one Activity class. Unlike most programming languages, in which the main() method is the entry point for that program or application to s 6 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 Like