मुख्य सामग्री पर जाएँ
Skillpedia
मोबाइल ऐप10k · #11918

adaptive

यह क्या करती है

यह स्किल Compose Android ऐप को अलग-अलग स्क्रीन आकार और डिवाइस के अनुसार बदलने का मार्गदर्शन देती है। इसमें navigation, मल्टी-पेन लेआउट, लिस्ट और रोटेशन के दौरान स्थिति बचाना शामिल है। यह उन Android डेवलपरों के लिए है जिनका ऐप फ़ोन से आगे भी काम करे।

कब इस्तेमाल करें

  • ✓जब आप चाहते हैं कि Android ऐप फ़ोन के साथ-साथ टैबलेट और फ़ोल्डेबल पर भी अच्छा चले।
  • ✓जब आपको मल्टी-पेन लेआउट या ऐसा navigation bar चाहिए जो स्क्रीन आकार के साथ बदले।
  • ✓जब आप चाहते हैं कि आपके ऐप की स्क्रीन और मीडिया प्लेबैक कॉन्फ़िगरेशन बदलने पर भी अपनी स्थिति रखें।

Skill का लिंक

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

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/android/skills/blob/main/jetpack-compose/adaptive/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरे Compose Android ऐप को टैबलेट, फ़ोल्डेबल और डेस्कटॉप विंडो के अनुसार ढालिए।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

स्किल पहले सुनिश्चित करती है कि बड़े स्क्रीन आकारों के लिए स्क्रीनशॉट टेस्ट मौजूद हैं, फिर navigation, लेआउट और लिस्ट को चरण-दर-चरण ढालती है। वह स्थिति बचाने और फ़ोल्डेबल सपोर्ट भी संभालती है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे 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

अक्सर पूछे जाने वाले सवाल

ऐप में पहले से क्या होना चाहिए?

ऐप अपनी स्क्रीन के लिए Jetpack Compose और Jetpack Navigation 3 इस्तेमाल करे। अगर नहीं करता, तो स्किल पहले माइग्रेशन का सुझाव देती है।

क्या यह टेस्ट जोड़ती है?

हाँ। यह सुनिश्चित करती है कि अलग-अलग फ़ॉर्म फ़ैक्टर पर मौजूदा UI जाँचने के लिए स्क्रीनशॉट टेस्ट मौजूद हों।

क्या यह माउस और कीबोर्ड सपोर्ट करती है?

हाँ। स्किल माउस जैसे पॉइंटिंग डिवाइस और कीबोर्ड से टेक्स्ट इनपुट को कवर करती है।

जानकारी

लेखक का मूल विवरण

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

लोकप्रियता

GitHub स्टार
10k
रैंकिंग में स्थान
#11918
लाइसेंस
Apache-2.0
अपडेट की गई
29/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

agp-9-upgrade

10k

आपके एजेंट को Android ऐप को Android Gradle Plugin 9 पर ले जाने और उसके breaking changes सुधारने में मदद करती है। मल्टीप्लेटफ़ॉर्म प्रोजेक्ट के लिए नहीं।

कोडिंगमोबाइल ऐप

camerax

10k

आपके एजेंट को CameraX से Android कैमरा फ़ीचर बनाने में मदद करती है, जिसमें वीडियो रिकॉर्डिंग, हार्डवेयर कंट्रोल, ML Kit और Media3 इफ़ेक्ट शामिल हैं।

कोडिंगमोबाइल ऐप

android-for-cars-parked-apps

10k

आपके एजेंट को Android वीडियो, गेम या ब्राउज़र ऐप को Android Auto और Android Automotive पर parked ऐप के रूप में चलाने के लिए ढालने में मदद करती है।

कोडिंगमोबाइल ऐप

appfunctions

10k

आपके एजेंट को Android ऐप के मुख्य काम ढूँढकर उन्हें AppFunctions के रूप में देने में मदद करती है, ताकि AI एजेंट और वॉइस कमांड उन्हें चला सकें।

AI और एजेंटएजेंट

मिलती-जुलती skills