TextView in Android using Jetpack Compose
Jetpack Compose is a new toolkit provided by Google. This is useful for designing beautiful UI designs. Android TextView 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 TextView in Android using Jetpack Compose.
Attributes of TextView Widget
Want a more fast-paced & competitive environment to learn the fundamentals of Android?
Click here to head to a guide uniquely curated by our experts with the aim to make you industry ready in no time!
|text||to set the text which we have to display inside our TextView.|
|style||to change the style of TextView in Android.|
|color||to change the color of TextView.|
|fontSize||to change the font size of our text.|
|fontWeight||to set the weight for our font ie. extra bold, dark, and many more|
|fontStyle||to set font style to italic.|
|fontFamily||to change the font family of our text.|
|letterSpacing||to set spacing in between letters of our TextView.|
|background||to set background color for our TextView.|
|shadow||to add shadow for our TextView.|
|textAlign||to change the alignment of our TextView.|
|modifier||the modifier is used to add padding to our TextView.|
Step by Step Implementation
Step 1: Create a New Project
To create a new project in the Android Studio Canary Version please refer to How to Create a new Project in Android Studio Canary Version with Jetpack Compose.
Step 2: Adding TextView in MainActivity.kt file
Navigate to the app > java > your app’s package name and open the MainActivity.kt file. Inside that file add the below code to it. Comments are added inside the code to understand the code in more detail.