Stats Row & Follow Button
Add interactive details to the card.
Stats Row & Follow Button is a free Jetpack Compose Academy lesson on CoddyKit — lesson 3 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 Jetpack Compose Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Add the Interactive Details
With the header done, you will add the lower half: a row of stats and a follow button that responds to taps. This is where the card comes alive. ⚡
One Stat Block
Each stat is two stacked Texts: a big number and a small label. A tiny Column holds them together as one neat block.
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Text("128")
Text("Posts")
}Emphasize the Number
The count should pop while the label stays quiet. Give the number a bold style and the label a smaller one.
Text("128", style = MaterialTheme.typography.titleMedium)
Text("Posts", style = MaterialTheme.typography.labelSmall)Put Stats in a Row
Three stat blocks sit side by side, so wrap them in a Row. Each block becomes a child laid out left to right.
Row {
StatBlock("128", "Posts")
StatBlock("4.2k", "Followers")
StatBlock("180", "Following")
}Space the Stats Evenly
Spread the blocks across the card with Arrangement.SpaceEvenly on the Row, so the gaps are equal and balanced.
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceEvenly
) { /* ... */ }Add the Follow Button
Below the stats, add a Button. Its onClick lambda runs your code the moment the user taps it.
Button(onClick = { /* follow */ }) {
Text("Follow")
}Make It Full Width
A primary action button reads best across the whole card. Add fillMaxWidth so it spans edge to edge.
Button(
onClick = { /* follow */ },
modifier = Modifier.fillMaxWidth()
) { Text("Follow") }Track the Follow State
The button should toggle between Follow and Following. Hold that with remember and mutableStateOf so the UI reacts to taps.
var following by remember { mutableStateOf(false) }Flip State on Tap
Inside onClick, flip the boolean. Compose notices the state changed and redraws the button with new text automatically.
Button(onClick = { following = !following }) {
Text(if (following) "Following" else "Follow")
}Wire It Into the Card
Drop the stats Row and the Button below the header inside the outer Column. The full card now reads top to bottom in order.
An Interactive Card
You now have stats, a follow button, and live state. Tapping really changes the screen, which is the heart of a declarative Compose UI. 🎉
Quick Check
What lets the button text update when tapped?
Recap: Stats and Action
You built a Row of evenly spaced stat blocks and a full-width follow button driven by remembered state. Next you will refactor it all into clean, reusable pieces.
Frequently asked questions
Is the “Stats Row & Follow Button” lesson free?
Yes — the full text of “Stats Row & Follow Button” is free to read here on the web, and the Jetpack Compose 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 Jetpack Compose Academy course, upgrade to CoddyKit PRO.
What will I learn in “Stats Row & Follow Button”?
Add interactive details to the card. You practise Jetpack Compose 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 Jetpack Compose Academy?
No prior experience is required. Jetpack Compose Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Stats Row & Follow Button” 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 Jetpack Compose Academy lesson?
Yes. Every Jetpack Compose 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.
All lessons in this course
- Sketch the Profile Card Layout
- Avatar, Name & Bio Section
- Stats Row & Follow Button
- Extract Reusable Composables