El Composable Image
Dibuje un recurso drawable en pantalla.
El Composable Image es una lección gratuita de Jetpack Compose Academy en CoddyKit. Esta es la lección 1 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Jetpack Compose Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Jetpack Compose Academy incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en 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! ✨
Preguntas frecuentes
¿La lección «El Composable Image» es gratis?
Sí — el texto completo de «El Composable Image» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Jetpack Compose Academy, actualiza a CoddyKit PRO. El curso de Jetpack Compose Academy incluye 4 lecciones en total.
¿Qué aprenderé en «El Composable Image»?
Dibuje un recurso drawable en pantalla. Practicas Jetpack Compose Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar Jetpack Compose Academy?
No se requiere experiencia previa. Jetpack Compose Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 1 de 4.
¿Cuánto tiempo toma la lección «El Composable Image»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de Jetpack Compose Academy?
Sí. Cada lección de Jetpack Compose Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- El Composable Image
- Iconos de Material con Icon
- ContentScale y recorte
- Recortar y dar forma a sus imágenes