What is Text In Jetpack Compose?​

What is Text In Jetpack Compose?

Beginner guide to Text in Jetpack Compose

In Android development, we used TextView in XML Layouts to show text.
In Jetpack Compose, we use the Text() composable function.

Here`s the simplest example:

 

Text(text=”Hello, Jetpack Compose!”)

 

This is one line is enough to place a text element on your screen.

Why use Jetpack Compose:

  • No Need to define views in XML.
  • Faster preview and updates.
  • Cleaner and more readable Kotlin code

 

Text In Jetpack Compose

Here`s how to apply basic style in Text: 

Text( 

         text = “Welcome To Programming Keeda”

         fontSize = 20.sp

         color = Color.Red

         fontWeight = FontWeight.Bold

         letterSpacing = 1.5.sp

)

 

Text Properties:

  • fontSize: The text size using sp(scale-independent pixels).
  • color: Defines the text color.
  • fontWeight: You can use values like FontWeight.Light , Normal , Bold
  • letterSpacing: space between letters fro better readability.

The  Text  composable is your got to tools for displaying any text in jetpack compose. With just one function you can create.

  • Simple  lables
  • Interactive text
  • Styled messages
  • Links and rich formatting.

 

👇 Drop your questions or ideas in the comments — and don’t forget to share this post with friends learning Android development!

 

📢 Follow Programming Keeda for more beginner-friendly Android tips and tutorials every week.

Leave a Comment

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply

    Your email address will not be published. Required fields are marked *