0Pricing
Jetpack Compose Academy · Lección

Color, alineación y desbordamiento

Aplique color al texto y gestione correctamente el contenido largo.

Color, alineación y desbordamiento es una lección gratuita de Jetpack Compose Academy en CoddyKit. Esta es la lección 3 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.

Beyond Black Text

Default text adopts your theme color, but you often want a specific tint. Compose lets you set color and handle long content with ease.

Tint with color

Pass a color to recolor any Text. Use Color values directly, or pull semantic colors from MaterialTheme for theme-aware results.

Text("Error", color = Color.Red)

Prefer Theme Colors

Hardcoded colors break in dark mode. Reach for MaterialTheme.colorScheme so your text stays readable on every background.

Text("Hi", color = MaterialTheme.colorScheme.primary)

Align the Text

Control horizontal alignment with textAlign. Center a title or justify a paragraph; it only matters when Text has width to fill.

Text("Centered", textAlign = TextAlign.Center)

Alignment Needs Width

For textAlign to show, the Text must be wider than its words, usually via fillMaxWidth. Otherwise it hugs the text and nothing shifts.

Text("Hi", modifier = Modifier.fillMaxWidth(),
     textAlign = TextAlign.Center)

The Overflow Problem

Real data can be longer than your space. Without a plan, text may push your layout or get awkwardly clipped. Overflow handling fixes this.

Cap with maxLines

Limit height by setting maxLines. The text will draw at most that many lines and quietly stop, keeping rows a predictable size.

Text(longBio, maxLines = 2)

Show an Ellipsis

Pair maxLines with overflow = TextOverflow.Ellipsis to trail off with three dots, signaling there is more to read.

Text(longBio, maxLines = 1,
     overflow = TextOverflow.Ellipsis)

Other Overflow Modes

TextOverflow also offers Clip, which simply cuts at the edge, and Visible, which lets text spill out. Ellipsis is the friendliest default. 🙂

Min Lines for Stability

Use minLines to reserve space so a card does not jump in height when one item has shorter text than another in a list.

Text(caption, minLines = 2, maxLines = 2)

Polished, Predictable Text

Color makes meaning clear, alignment guides the eye, and overflow rules keep layouts stable no matter how long the real data gets.

Quick Check

You want a one-line label that ends with three dots when too long. What do you set?

Recap

You learned to tint text with color, position it using textAlign, and tame long content with maxLines plus overflow. Layouts stay tidy. ✨

Preguntas frecuentes

¿La lección «Color, alineación y desbordamiento» es gratis?

Sí — el texto completo de «Color, alineación y desbordamiento» 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 «Color, alineación y desbordamiento»?

Aplique color al texto y gestione correctamente el contenido largo. 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 3 de 4.

¿Cuánto tiempo toma la lección «Color, alineación y desbordamiento»?

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

  1. El Composable Text
  2. Tamaño, peso y estilo de fuente
  3. Color, alineación y desbordamiento
  4. AnnotatedString: texto enriquecido combinado
← Volver a Jetpack Compose Academy