0Pricing
Jetpack Compose Academy · Lezione

La Composable Image

Disegni sullo schermo una risorsa drawable.

La Composable Image è 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.

Pictures, the Compose Way

Every app shows pictures, and in Compose you draw them with the Image composable. It is the declarative replacement for the old ImageView. 🖼️

You Need a Painter

Image does not take a raw resource id. It takes a painter, a small object that knows how to draw your picture onto the screen.

painterResource Loads Drawables

To turn a drawable in res into a painter, you call painterResource with its resource id. This reads your PNG or vector asset.

val logo = painterResource(id = R.drawable.logo)

Your First Image

Pass that painter to Image and it appears on screen. This single line draws your drawable wherever the composable sits.

Image(painter = painterResource(R.drawable.logo), contentDescription = null)

contentDescription Is Required

Image always asks for a contentDescription. Screen readers speak it aloud, so describe the picture in a few clear words.

Image(painter = logo, contentDescription = "Company logo")

Decorative? Pass null

If a picture is purely decorative and adds no meaning, set contentDescription to null so TalkBack skips it instead of reading noise.

Vectors Scale Cleanly

Compose loves vector drawables. A vector stays razor sharp at any size because it is math, not fixed pixels, so it never looks blurry.

Size It with a Modifier

An Image draws at the bitmap size by default. Add a Modifier.size to make it exactly the dimensions your layout needs.

Image(painter = logo, contentDescription = null, modifier = Modifier.size(96.dp))

Bitmaps from the Network

painterResource only handles local assets. For remote URLs you reach for a loader library, the most popular being Coil with rememberAsyncImagePainter.

Tinting an Image

You can recolor a simple image with a colorFilter. This is great for monochrome icons you want to match your theme color.

Image(painter = logo, contentDescription = null,
    colorFilter = ColorFilter.tint(Color.Blue))

Image vs Icon

Use Image for photos and rich artwork. For small, theme-tinted symbols, the lighter Icon composable is usually the better choice.

Quick Check

Which argument does the Image composable always require alongside the painter?

Recap: Drawing Images

You learned that Image draws a painter from painterResource, always needs a contentDescription, and sizes with a modifier. Next up: Material icons! ✨

Domande Frequenti

La lezione «La Composable Image» è gratuita?

Sì — il testo completo di «La Composable Image» è 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 Image»?

Disegni sullo schermo una risorsa drawable. 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 Image»?

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 Image
  2. Icone Material con Icon
  3. ContentScale e ritaglio
  4. Ritagliare e dare forma alle immagini
← Torna a Jetpack Compose Academy