Saltar al contenido
Skillpedia
Apps móviles10 mil · #11918

adaptive

Qué hace

Esta skill guía la adaptación de una app de Android hecha con Compose a distintos tamaños de pantalla y dispositivos. Cubre la navegación, los diseños de varios paneles, las listas y el mantenimiento del estado al girar el dispositivo. Es para desarrolladores de Android cuya app debe funcionar más allá de los teléfonos.

Cuándo usarla

  • ✓Cuando quieres que una app de Android funcione bien en tablets y plegables, además de en teléfonos.
  • ✓Cuando necesitas un diseño de varios paneles o una barra de navegación que cambie con el tamaño de la pantalla.
  • ✓Cuando quieres que las pantallas y la reproducción multimedia de tu app mantengan su estado tras los cambios de configuración.

Link de la skill

https://github.com/android/skills/blob/main/jetpack-compose/adaptive/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/android/skills/blob/main/jetpack-compose/adaptive/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“Haz que mi app de Android con Compose se adapte a tablets, plegables y ventanas de escritorio.”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

La skill empieza asegurándose de que existan pruebas de capturas de pantalla para los tamaños principales, y después hace que la navegación, los diseños y las listas se adapten paso a paso. También gestiona la conservación del estado y el soporte para plegables.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de GitHub.

Prerequisites

The app must:

  • Use Compose for all screens. If it's still using Fragments or Views, suggest using the XML to Compose skill to migrate those screens.
  • Use Jetpack Navigation 3. If it doesn't, suggest the Navigation 3 skill to migrate the app.

Workflow to make an app adaptive

To make an app adaptive, follow these steps or a subset of them adapting to the task.

  • Step 1: Verify current UI
  • Step 2: Make the navigation bar adaptive
  • Step 3: Add multi-pane layouts
  • Step 4: Make vertical lists adaptive by changing the number of columns
  • Step 5: Hide app bars when scrolling
  • Step 6: Preserve UI state across configuration changes
  • Step 7: Add desktop experiences
  • Step 8: Support foldable devices

Step 1. Verify current UI

Ensure that screenshot tests exist to verify the current UI on different form factors. If they don't exist, add the Compose Preview Screenshot Testing tool. Use the following annotation to create previews for all the major form factors. For example:

@Preview(name = "Phone", device = Devices.PHONE, showBackground = true)
@Preview(name = "Foldable", device = Devices.FOLDABLE, showBackground = true)
@Preview(name = "Tablet", device = Devices.TABLET, showBackground = true)
@Preview(name = "Desktop", device = Devices.DESKTOP, showBackground = true)
annotation class FormFactorPreviews

@PreviewTest
@FormFactorPreviews
@Composable
fun FeedScreenPreview() {
    SnippetsTheme {
        Box {
            Text("My Screen")
        }
    }
}
<br />

Step 2. Make the navigation bar adaptive

Bottom navigation bars are optimized for touch input when the user is holding a phone in portrait mode. On larger screen hand-held devices, like tablets and unfolded foldables, the navigation area must be accessible from the edge of the screen (navigation rail).

If you need to provide more screen space for the content, hide the navigation area. Examples of this include:

  • Hiding the navigation bar when the user scrolls down and showing it again when the user scrolls up. The assumption is that when the user is scrolling down, they are consuming content but when scrolling up they are trying to navigate away from that content.
  • Hiding the navigation area when its content is distracting. For example, in camera previews or when displaying a full-screen photo.

When the detail screen is displayed full-screen on mobile, full-screen mode must be deactivated on larger screens.

Steps to migrate:

  • Locate the existing navigation bar.
  • Convert each item to a NavigationSuiteItem.
  • Identify whether the navigation bar's visibility changes. For example, if it is wrapped with an AnimatedContent or AnimatedVisibility composable. If so, follow the guidance in the "Control navigation area visibility".
  • Replace the container that held the navigation bar (often a Scaffold) with NavigationSuiteScaffold from the Material 3 adaptive layouts library.
  • Supply the navigation items using the navigationItems parameter of NavigationSuiteScaffold.

Step 2.1. Control navigation area visibility

If the navigation bar's visibility changes - it is hidden under certain scenarios or on certain screens - this behavior must be maintained with the adaptive navigation area. This is done using NavigationSuiteScaffold's state parameter.

Steps to migrate:

  • Identify the scenarios under which the navigation bar is hidden. This is usually done with a boolean variable for the visibility. Use isNavBarVisible or shouldShowNavBar as the variable name.
  • Create an instance of NavigationSuiteScaffoldState using rememberNavigationSuiteScaffoldState() and pass it to NavigationSuiteScaffold.
  • When the navigation area visibility changes, use a LaunchedEffect to call show or hide on the NavigationSuiteScaffoldState.

For example:

// Pass this variable to any composable that needs to control the navigation area visibility
var isNavBarVisible by remember { mutableStateOf(true) }
val scaffoldVisibilityState = rememberNavigationSuiteScaffoldState()

NavigationSuiteScaffold(
    navigationSuiteItems = navItems,
    state = scaffoldVisibilityState
) {
    // Main content
}

LaunchedEffect(isNavBarVisible){
    if (isNavBarVisible) {
        scaffoldVisibilityState.show()
    } else {
        scaffoldVisibilityState.hide()
    }
}
<br />

Step 3. Add multi-pane layouts using Navigation 3

Preguntas frecuentes

¿Qué debe usar ya la app?

La app debe usar Jetpack Compose para sus pantallas y Jetpack Navigation 3. Si no es así, la skill propone migrar antes.

¿Añade pruebas?

Sí. Se asegura de que existan pruebas de capturas de pantalla para comprobar la interfaz actual en distintos formatos.

¿Admite ratón y teclado?

Sí. La skill cubre dispositivos de puntero como el ratón y la entrada de texto con teclado.

Detalles

Descripción original del autor

Instructions to make or update an app's UI so that it adapts to different Android devices including phones, tablets, foldables, laptops, desktop, TV, Auto, and XR. It includes how to handle different window sizes, pointing devices (such as mouse) and text entry devices (such as keyboard) using the Compose MediaQuery API, and how to preserve UI, navigation, scroll, and media playback state across configuration changes (such as folding/unfolding a foldable, rotating a device, or resizing a window). It also covers multi-pane layouts using Navigation3 Scenes, adaptive UI components (such as button

repo: android/skills

Popularidad

Estrellas en GitHub
10 mil
Posición en el ranking
#11918
Licencia
Apache-2.0
Actualizada
29/10/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas