Styling Text
Fonts, size, weight, and color.
Styling Text is a free Android Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Android Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Why Style Text?
In Jetpack Compose, the Text composable shows words on screen. By default it uses a plain look, but you can change its size, color, and weight.
Styling helps users read your app. A title should look bigger and bolder than body text.
You style Text by passing extra parameters to it.
Text("Hello Compose")Making Text Bigger
The fontSize parameter controls how large the text is. Sizes use the sp unit, which scales with the user's font settings.
To use sp, add .sp after a number, like 24.sp.
Text(
text = "Big Title",
fontSize = 24.sp
)Bold and Weight
Use fontWeight to make text thicker or thinner. The most common value is FontWeight.Bold.
Other options include FontWeight.Light, FontWeight.Normal, and FontWeight.SemiBold.
Text(
text = "Important",
fontWeight = FontWeight.Bold
)Italic Text
The fontStyle parameter can slant text. Set it to FontStyle.Italic for an italic look.
Italics are useful for quotes or emphasis.
Text(
text = "A quote",
fontStyle = FontStyle.Italic
)Coloring Text
The color parameter changes the text color. You can pass a Color value such as Color.Red or Color.Blue.
Choose colors with good contrast so text stays easy to read.
Text(
text = "Warning",
color = Color.Red
)Aligning Text
Use textAlign to position text inside its space. Common values are TextAlign.Center, TextAlign.Start, and TextAlign.End.
Centering works best when the Text fills the full width.
Text(
text = "Centered",
textAlign = TextAlign.Center
)Letter Spacing
The letterSpacing parameter adds gaps between characters. It also uses the sp unit.
A little extra spacing can make headings feel more open and modern.
Text(
text = "SPACED",
letterSpacing = 2.sp
)Combining Styles
You can mix many parameters at once. A bold, large, blue title is just one Text call with several values.
Compose reads each parameter and applies them all together.
Text(
text = "Welcome",
fontSize = 28.sp,
fontWeight = FontWeight.Bold,
color = Color.Blue
)Using TextStyle
Instead of many separate parameters, you can group them in a TextStyle object and pass it to the style parameter.
This is handy when you reuse the same look in several places.
Text(
text = "Styled",
style = TextStyle(
fontSize = 20.sp,
color = Color.Magenta
)
)Handling Long Text
Long text can overflow its area. Use maxLines to limit lines and overflow to show dots when text is cut.
TextOverflow.Ellipsis adds a trailing ... for hidden text.
Text(
text = "A very long sentence...",
maxLines = 1,
overflow = TextOverflow.Ellipsis
)Underline and Decoration
The textDecoration parameter can add an Underline or a LineThrough.
Underlines often mark links, while line-through can show removed or old prices.
Text(
text = "Link",
textDecoration = TextDecoration.Underline
)Quick Check
Test what you learned about styling Text.
Recap
You learned to style Text with fontSize (in sp), fontWeight for bold, fontStyle for italic, and color for tint.
You can also align text, add letter spacing, decorations, and group everything in a TextStyle.
Next, you'll make buttons that respond to taps.
Frequently asked questions
Is the “Styling Text” lesson free?
Yes — the full text of “Styling Text” is free to read here on the web, and the Android Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Android Academy course, upgrade to CoddyKit PRO.
What will I learn in “Styling Text”?
Fonts, size, weight, and color. You practise Android Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Android Academy?
No prior experience is required. Android Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Styling Text” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Android Academy lesson?
Yes. Every Android Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.