0Pricing
Jetpack Compose Academy · Lezione

La Composable Text

Mostri una stringa e ne controlli gli aspetti fondamentali.

La Composable Text è una lezione Jetpack Compose Academy gratuita su CoddyKit. Questa è la lezione 1 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Jetpack Compose Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Jetpack Compose Academy include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

Meet Text

In Compose, you put words on screen with the Text composable. It is the simplest building block you will use in almost every screen.

Pass a String

Give Text a string and it renders instantly. No XML, no findViewById, just a function call describing what you want shown.

Text("Hello, Compose!")

It Is Just a Function

Text is a composable function, not a class you inflate. You call it inside other composables, exactly like calling any Kotlin function. 🙂

Where Text Lives

You write Text inside a composable function such as your screen. Compose reads your code top to bottom and draws each element it finds.

@Composable
fun Greeting() {
    Text("Welcome")
}

Default Styling

With no extra arguments, Text uses sensible defaults from your theme: a readable size, the on-surface color, and the standard font.

Strings from Resources

For real apps, pull text from stringResource instead of hardcoding. This keeps your app translatable into every language you ship.

Text(stringResource(R.string.greeting))

Combine with Variables

Because it is plain Kotlin, you can build the string from variables and templates before passing it to Text. Logic and UI live together.

val name = "Ada"
Text("Hi, " + name)

Many Texts, One Screen

Need several lines? Just call Text multiple times. Each call is one independent element you can style on its own later.

maxLines Keeps It Tidy

Long content can be capped with maxLines so a label never grows taller than you expect. It simply stops drawing extra lines.

Text("A very long bio...", maxLines = 1)

Reacts to State

When the string you pass changes, Text redraws automatically. You never call an update method; Compose tracks the value for you.

Your First Words

That is the whole idea: describe the text you want, and Compose paints it. Everything fancier is just extra arguments on this same call.

Quick Check

Which line correctly shows a greeting in Compose?

Recap

You met Text, the core composable for showing words. Pass it a string, lean on theme defaults, and it redraws whenever the value changes. 🎉

Domande Frequenti

La lezione «La Composable Text» è gratuita?

Sì — il testo completo di «La Composable Text» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Jetpack Compose Academy, passa a CoddyKit PRO. Il corso Jetpack Compose Academy include 4 lezioni in totale.

Cosa imparerò in «La Composable Text»?

Mostri una stringa e ne controlli gli aspetti fondamentali. Eserciti Jetpack Compose Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare Jetpack Compose Academy?

Non è richiesta alcuna esperienza precedente. Jetpack Compose Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 1 di 4.

Quanto tempo richiede la lezione «La Composable Text»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione Jetpack Compose Academy?

Sì. Ogni lezione Jetpack Compose Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. La Composable Text
  2. Dimensione, peso e stile del carattere
  3. Colore, allineamento e overflow
  4. AnnotatedString: testo misto avanzato
← Torna a Jetpack Compose Academy