Mulai 27 Maret 2025, sebaiknya gunakan android-latest-release
, bukan aosp-main
, untuk mem-build dan berkontribusi pada AOSP. Untuk mengetahui informasi selengkapnya, lihat Perubahan pada AOSP.
Pola dan komponen
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Di Android 8.0, menu Setelan mendapatkan beberapa komponen dan widget yang
mencakup penggunaan umum. Produsen dan developer perangkat sebaiknya menggunakan
komponen umum saat memperluas aplikasi Setelan sehingga antarmuka pengguna baru tetap
konsisten dengan UI Setelan yang ada.
Berikut adalah ringkasan peningkatan:
- Perubahan perilaku pemisah di framework Preference library dukungan. Pembagi
kini digambar di antara kategori.
- Perubahan tema ActionBar. ActionBar kini menggunakan tema warna terang, dengan
teks warna aksen.
- Tata letak preferensi baru. Ruang untuk ikon tetap ada meskipun preferensi
tidak memiliki ikon.
Widget baru:
- Widget header untuk detail aplikasi. Menampilkan ikon aplikasi, label aplikasi, dan
informasi lainnya.
- Tombol luaskan di beberapa halaman. Halaman dapat dimulai dalam keadaan diciutkan dan menyembunyikan item yang kurang penting hingga pengguna mengklik tombol luaskan.
- UI pemilih aplikasi default:
- UI untuk memilih browser default, aplikasi telepon default, dll.
- Dulunya dialog, kini menjadi UI berbasis tombol pilihan layar penuh.
- Preferensi gaya "MasterSwitch". Ini adalah preferensi dengan dua target
klik. Target kiri mengarah ke fragmen atau intent subset. Target kanan adalah
tombol tombol, yang mengontrol aktif/nonaktif untuk seluruh halaman.
Contoh dan sumber
- Perilaku pemisah
- Semua halaman di Setelan diubah untuk menggunakan perilaku pemisah baru.
- Perilaku pemisah ditentukan sebagai ThemeOverlay di:
packages/apps/Settings/res/values/styles_preference.xml
- Perubahan tema ActionBar
- Semua halaman di Setelan diubah untuk menggunakan tema ActionBar baru.
- Tema ditentukan di Theme.DeviceDefault.Settings
- Tata letak preferensi baru
- Banyak halaman di Setelan kini menggunakan tata letak preferensi baru.
- Anda dapat menemukan kodenya di:
packages/apps/Settings/res/values/styles_preference.xml
- Widget header aplikasi
- Sebagian besar halaman informasi aplikasi di Setelan sudah menerapkan
header Aplikasi baru.
- Contoh dan kode dapat ditemukan di:
packages/apps/Settings/src/com/android/settings/applications/AppHeaderController.java
- Tombol luaskan
- Pemilih aplikasi default
- Anda dapat menemukan kode untuk class dasar di:
packages/apps/Settings/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragment.java
- Ada beberapa subclass DefaultAppPickerFragment, yang masing-masing menerapkan pemilih untuk intent yang berbeda.
- Preferensi gaya MasterSwitch
- Kode ada di:
https://cs.android.com/android/platform/superproject/+/main:packages/apps/Settings/src/com/android/settings/wifi/WifiPrimarySwitchPreferenceController.java
- Contoh kasus penggunaan adalah tombol utama Wi-Fi. Anda dapat menemukan contohnya di:
packages/apps/Settings/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java
Implementasi
Produsen perangkat dapat mulai menggunakan semua komponen baru secara langsung.
Jika OEM memutuskan untuk menerapkan preferensi gaya "MasterSwitch" baru atau pemilih aplikasi
default, mereka harus mengikuti contoh dalam dokumen ini dan file referensi
(Javadoc) yang ditulis dengan setiap komponen untuk mengetahui detail selengkapnya.
Menyesuaikan menu setelan
- Perilaku pemisah. Untuk mengubah cara pemisah digambar, perbarui gaya untuk pemisah Setelan dan
ubah nilai untuk hal berikut:
allowDividerAbove
allowDividerBelow
allowDividerAfterLastItem
- Warna tema ActionBar. Aktivitas harus menggunakan
Theme.DeviceDefault.Settings
sebagai temanya, atau
membuat tema kustom menggunakan Theme.DeviceDefault.Settings
sebagai induk.
- Widget header aplikasi. Gunakan penyetel di AppHeaderController untuk menyesuaikan setiap kolom dan memanggil
build()
setelah semua kolom ditetapkan.
- Tombol luaskan:
- Untuk menonaktifkan fungsi sepenuhnya, ganti konstruktor untuk
ProgressiveDisclosureMixin dan tetapkan keepExpanded ke true.
- Untuk menyesuaikan jumlah item yang akan ditampilkan pada awalnya, panggil
metode
ProgressiveDisclosureMixin.setTileLimit()
selama metode
onAttach(Context)
fragmen.
Konten dan contoh kode di halaman ini tunduk kepada lisensi yang dijelaskan dalam Lisensi Konten. Java dan OpenJDK adalah merek dagang atau merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-27 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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."]]