Pular para o conteúdo
Skillpedia
Apps de celular10 mil · #11918

adaptive

O que ela faz

Esta skill orienta a criação de um app Android em Compose que responde a diferentes tamanhos de tela e dispositivos. Cobre navegação, layouts de múltiplos painéis, listas e a manutenção do estado durante a rotação. É para desenvolvedores Android cujo app deve funcionar além dos celulares.

Quando usar

  • ✓Quando você quer que um app Android funcione bem em tablets e dobráveis, além de celulares.
  • ✓Quando você precisa de um layout de múltiplos painéis ou de uma barra de navegação que muda com o tamanho da tela.
  • ✓Quando você quer que as telas e a reprodução de mídia do seu app mantenham o estado durante mudanças de configuração.

Link da skill

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

Copie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.

Como usar

O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.

Mensagem pronta para colar

Use esta skill para me ajudar: https://github.com/android/skills/blob/main/jetpack-compose/adaptive/SKILL.md Leia o arquivo SKILL.md desse link e siga as instruções dele na minha tarefa.
Quer que a sua IA encontre skills como esta sozinha?Instale o MCP grátis do Skillpedia: uma linha, e ela pesquisa entre 15.000+ skills antes de cada tarefa.Instalar em 1 minuto →

Exemplo do que pedir para a IA

“Faça o meu app Android em Compose se adaptar a tablets, dobráveis e janelas de computador.”

5 skills novas por semana. 1 minuto de leitura.

Como funciona

A skill começa garantindo que existam testes de captura de tela para os principais tamanhos de tela e depois faz a navegação, os layouts e as listas se adaptarem passo a passo. Também cuida da preservação do estado e do suporte a dobráveis.

Conteúdo técnico (SKILL.md original)

Texto original do autor, em inglês, direto do 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

Perguntas frequentes

O que o app já precisa usar?

O app precisa usar Jetpack Compose para as telas e o Jetpack Navigation 3. Se não usar, a skill sugere primeiro a migração.

Ela adiciona testes?

Sim. Ela garante que existam testes de captura de tela para verificar a interface atual em diferentes formatos de tela.

Ela oferece suporte a mouse e teclado?

Sim. A skill cobre dispositivos de apontamento, como mouse, e a entrada de texto com teclado.

Detalhes

Descrição original do 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

Popularidade

Estrelas no GitHub
10 mil
Posição no ranking
#11918
Licença
Apache-2.0
Atualizada em
29/10/2026

Essa skill é útil?

0

Entre para votar.

Comentários

  • …

Mais skills deste repositório

Skills parecidas