हमारा सुझाव है कि 27 मार्च, 2025 से AOSP को बनाने और उसमें योगदान देने के लिए, aosp-main
के बजाय android-latest-release
का इस्तेमाल करें. ज़्यादा जानकारी के लिए, AOSP में हुए बदलाव लेख पढ़ें.
पैटर्न और कॉम्पोनेंट
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
Android 8.0 में, सेटिंग मेन्यू में कई कॉम्पोनेंट और विजेट जोड़े गए हैं. इनसे, आम तौर पर इस्तेमाल होने वाले काम किए जा सकते हैं. डिवाइस बनाने वाली कंपनियों और डेवलपर को सलाह दी जाती है कि वे सेटिंग ऐप्लिकेशन को बड़ा करते समय, सामान्य कॉम्पोनेंट का इस्तेमाल करें, ताकि नए यूज़र इंटरफ़ेस, सेटिंग के मौजूदा यूज़र इंटरफ़ेस के मुताबिक बने रहें.
यहां इन सुधारों की खास जानकारी दी गई है:
- सहायता लाइब्रेरी के Preference फ़्रेमवर्क में, डिवाइडर के व्यवहार में बदलाव. अब कैटगरी के बीच डिवाइडर दिख रहा है.
- ActionBar की थीम बदलना. ActionBar अब हल्के रंग वाली थीम का इस्तेमाल करता है. साथ ही, इसमें ऐक्सेंट कलर वाला टेक्स्ट भी होता है.
- प्राथमिकता का नया लेआउट. किसी प्राथमिकता के लिए आइकॉन न होने पर भी, आइकॉन के लिए जगह बनी रहती है.
नए विजेट:
- ऐप्लिकेशन की जानकारी के लिए हेडर विजेट. ऐप्लिकेशन का आइकॉन, ऐप्लिकेशन का लेबल, और अन्य जानकारी दिखाता है.
- कुछ पेजों पर, 'बड़ा करें' बटन. पेज को छोटा करके शुरू किया जा सकता है. साथ ही, जब तक उपयोगकर्ता 'बड़ा करें' बटन पर क्लिक नहीं करता, तब तक कम अहम आइटम छिपे रह सकते हैं.
- ऐप्लिकेशन पिकर का डिफ़ॉल्ट यूज़र इंटरफ़ेस (यूआई):
- डिफ़ॉल्ट ब्राउज़र, डिफ़ॉल्ट फ़ोन ऐप्लिकेशन वगैरह चुनने के लिए यूज़र इंटरफ़ेस (यूआई).
- पहले यह एक डायलॉग था, लेकिन अब यह फ़ुल स्क्रीन रेडियो बटन पर आधारित यूज़र इंटरफ़ेस (यूआई) है.
- "MasterSwitch" स्टाइल की प्राथमिकता. यह दो क्लिक टारगेट वाली प्राथमिकता है. बाईं ओर मौजूद टारगेट, किसी सबसेटिंग फ़्रैगमेंट या इंटेंट पर ले जाता है. राइट टारगेट एक स्विच टॉगल है, जो पूरे पेज के लिए चालू/बंद को कंट्रोल करता है.
उदाहरण और सोर्स
- डिवाइडर का व्यवहार
- सेटिंग के सभी पेजों में बदलाव किया गया है, ताकि डिवाइडर के नए तरीके का इस्तेमाल किया जा सके.
- डिवाइडर के व्यवहार को ThemeOverlay के तौर पर तय किया गया है:
packages/apps/Settings/res/values/styles_preference.xml
- ActionBar की थीम बदलना
- ActionBar की नई थीम का इस्तेमाल करने के लिए, सेटिंग के सभी पेजों में बदलाव किए गए हैं.
- थीम की जानकारी, Theme.DeviceDefault.Settings में दी गई है
- प्राथमिकता का नया लेआउट
- सेटिंग में मौजूद कई पेज, अब प्राथमिकता के नए लेआउट का इस्तेमाल कर रहे हैं.
- आपको कोड यहां मिल सकता है:
packages/apps/Settings/res/values/styles_preference.xml
- ऐप्लिकेशन हेडर विजेट
- सेटिंग में ऐप्लिकेशन की जानकारी वाले ज़्यादातर पेजों पर, ऐप्लिकेशन का नया हेडर पहले से लागू है.
- उदाहरण और कोड यहां देखे जा सकते हैं:
packages/apps/Settings/src/com/android/settings/applications/AppHeaderController.java
- बड़ा करें बटन
- डिफ़ॉल्ट ऐप्लिकेशन पिकर
- आपको बेस क्लास का कोड यहां मिल सकता है:
packages/apps/Settings/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragment.java
- DefaultAppPickerFragment के कई सबक्लास हैं. हर सबक्लास, अलग-अलग इंटेंट के लिए पिकर लागू करता है.
- MasterSwitch स्टाइल की प्राथमिकता
- कोड यहां है:
https://cs.android.com/android/platform/superproject/+/main:packages/apps/Settings/src/com/android/settings/wifi/WifiPrimarySwitchPreferenceController.java
- इस्तेमाल के उदाहरण के तौर पर, वाई-फ़ाई का प्राइमरी स्विच है. इसका उदाहरण यहां देखें:
packages/apps/Settings/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java
लागू करना
डिवाइस बनाने वाली कंपनियां, सभी नए कॉम्पोनेंट का इस्तेमाल तुरंत शुरू कर सकती हैं.
अगर OEM, "MasterSwitch" स्टाइल की नई प्राथमिकता या डिफ़ॉल्ट ऐप्लिकेशन पिकर लागू करना चाहते हैं, तो उन्हें ज़्यादा जानकारी के लिए, इस दस्तावेज़ में दिए गए उदाहरणों और हर कॉम्पोनेंट के साथ लिखी गई रेफ़रंस फ़ाइलों (Javadoc) का पालन करना चाहिए.
सेटिंग मेन्यू को पसंद के मुताबिक बनाना
- डिवाइडर का व्यवहार. डिवाइडर के दिखने का तरीका बदलने के लिए, सेटिंग डिवाइडर के स्टाइल को अपडेट करें और इनकी वैल्यू बदलें:
allowDividerAbove
allowDividerBelow
allowDividerAfterLastItem
- ActionBar की थीम का रंग. गतिविधियों को अपनी थीम के तौर पर
Theme.DeviceDefault.Settings
का इस्तेमाल करना चाहिए या Theme.DeviceDefault.Settings
को पैरंट के तौर पर इस्तेमाल करके, कस्टम थीम बनानी चाहिए.
- ऐप्लिकेशन हेडर विजेट. हर फ़ील्ड को पसंद के मुताबिक बनाने के लिए, AppHeaderController में सेटर का इस्तेमाल करें. साथ ही, सभी फ़ील्ड सेट होने के बाद,
build()
को कॉल करें.
- बड़ा करें बटन:
- इस सुविधा को पूरी तरह से बंद करने के लिए, ProgressiveDisclosureMixin के लिए कन्स्ट्रक्टर को बदलें और keepExpanded को 'सही' पर सेट करें.
- शुरुआत में कितने आइटम दिखाने हैं, यह तय करने के लिए फ़्रैगमेंट के
onAttach(Context)
तरीके के दौरान ProgressiveDisclosureMixin.setTileLimit()
तरीका कॉल करें.
इस पेज पर मौजूद कॉन्टेंट और कोड सैंपल कॉन्टेंट के लाइसेंस में बताए गए लाइसेंस के हिसाब से हैं. Java और OpenJDK, Oracle और/या इससे जुड़ी हुई कंपनियों के ट्रेडमार्क या रजिस्टर किए हुए ट्रेडमार्क हैं.
आखिरी बार 2025-07-27 (UTC) को अपडेट किया गया.
[[["समझने में आसान है","easyToUnderstand","thumb-up"],["मेरी समस्या हल हो गई","solvedMyProblem","thumb-up"],["अन्य","otherUp","thumb-up"]],[["वह जानकारी मौजूद नहीं है जो मुझे चाहिए","missingTheInformationINeed","thumb-down"],["बहुत मुश्किल है / बहुत सारे चरण हैं","tooComplicatedTooManySteps","thumb-down"],["पुराना","outOfDate","thumb-down"],["अनुवाद से जुड़ी समस्या","translationIssue","thumb-down"],["सैंपल / कोड से जुड़ी समस्या","samplesCodeIssue","thumb-down"],["अन्य","otherDown","thumb-down"]],["आखिरी बार 2025-07-27 (UTC) को अपडेट किया गया."],[],[],null,["# Patterns and components\n\nIn Android 8.0, the Settings menu gains several components and widgets that\ncover common uses. Device manufacturers and developers are encouraged to use the\ncommon components when extending the Settings app so new user interfaces stay\nconsistent with the existing Settings UI.\n\n\nHere is a summary of improvements:\n\n- Divider behavior change in support library Preference framework. Divider is now drawn between categories.\n- ActionBar theme change. The ActionBar now uses light color theme, with accent color text.\n- New preference layout. The space for icons remains even when a preference has no icon.\n\n\nNew widgets:\n\n- A header widget for app details. Displays app icon, app label and other information.\n- An expand button on some pages. Page can start as collapsed and hide less important items until user clicks expand button.\n- Default app picker UI:\n - The UI for choosing default browser, default phone app, etc.\n - Formerly a dialog, now it's a full screen radio button-based UI.\n- A \"MasterSwitch\" style preference. This is a preference with two click targets. Left target leads to a subsetting fragment or intent. Right target is a switch toggle, controlling on/off for the entire page.\n\nExamples and source\n-------------------\n\n- Divider behavior\n - All pages in Settings are modified to use the new divider behavior.\n - The divider behavior is defined as a ThemeOverlay in: \n `packages/apps/Settings/res/values/styles_preference.xml`\n- ActionBar theme change\n - All pages in Settings are modified to use the new ActionBar theme.\n - The theme is defined in Theme.DeviceDefault.Settings\n- New preference layout\n - Many pages in Settings are now using the new preference layout.\n - You can find the code in: \n `packages/apps/Settings/res/values/styles_preference.xml`\n- App header widget\n - Most app information pages in Settings are already implementing the new App header.\n - Examples and code can be found at: \n `packages/apps/Settings/src/com/android/settings/applications/AppHeaderController.java`\n- Expand button\n - Examples and code can be found at: \n `packages/apps/Settings/src/com/android/settings/dashboard/ProgressiveDisclosureMixin.java`\n\n **Note:** This component must be used together with\n DashboardFragment. (See more details about DashboardFragment in [Updated Information Architecture](/docs/core/settings/info-architecture).)\n- Default app picker\n - You can find the code for base class in: \n `packages/apps/Settings/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragment.java`\n - There are several subclasses of DefaultAppPickerFragment, each implementing a picker for different intent.\n- *MasterSwitch* style preference\n - Code is at: `https://cs.android.com/android/platform/superproject/+/main:packages/apps/Settings/src/com/android/settings/wifi/WifiPrimarySwitchPreferenceController.java`\n - An example use case is Wi-Fi primary switch. You can find an example at: `packages/apps/Settings/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java`\n\nImplementation\n--------------\n\n\nDevice manufacturers can start using all of the new components out of the box.\nIf OEMs decide to implement a new \"MasterSwitch\" style preference or default app\npicker, they should follow the examples in this document and the reference files\n(Javadoc) written with each component for more details.\n\nCustomize the settings menu\n---------------------------\n\n- Divider behavior. To change how divider is drawn, update the style for Settings dividers and change the value for the following:\n - `allowDividerAbove`\n - `allowDividerBelow`\n - `allowDividerAfterLastItem`\n- ActionBar theme color. Activities should use `Theme.DeviceDefault.Settings` as their theme, or create a custom theme using `Theme.DeviceDefault.Settings` as parent.\n- App header widget. Use setters in AppHeaderController to customize each field and call `build()` once all fields are set.\n- Expand button:\n - To fully disable the functionality, override the constructor for ProgressiveDisclosureMixin and set keepExpanded to true.\n - To customize how many items to show initially, call the `ProgressiveDisclosureMixin.setTileLimit()` method during fragment's `onAttach(Context)` method."]]