A Composable Image
Desenhe um recurso gráfico na tela.
A Composable Image é uma aula grátis de Jetpack Compose Academy no CoddyKit. Esta é a aula 1 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Jetpack Compose Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Jetpack Compose Academy inclui 4 aulas no total.
Partes desta aula ainda não foram traduzidas e aparecem em inglês.
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! ✨
Perguntas Frequentes
A aula “A Composable Image” é grátis?
Sim — o texto completo de “A Composable Image” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Jetpack Compose Academy, atualize para CoddyKit PRO. O curso de Jetpack Compose Academy inclui 4 aulas no total.
O que vou aprender em “A Composable Image”?
Desenhe um recurso gráfico na tela. Você pratica Jetpack Compose Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.
Preciso ter experiência prévia para começar Jetpack Compose Academy?
Nenhuma experiência prévia é necessária. Jetpack Compose Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 1 de 4.
Quanto tempo leva a aula “A Composable Image”?
A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.
Posso escrever e executar código nesta aula de Jetpack Compose Academy?
Sim. Cada aula de Jetpack Compose Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.
Todas as aulas deste curso
- A Composable Image
- Ícones do Material com Icon
- ContentScale e Recorte
- Recortando e Dando Forma às Imagens