Memigrasikan tema XML ke Compose
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Saat memperkenalkan Compose di aplikasi yang ada, Anda perlu memigrasikan tema di XML untuk menggunakan MaterialTheme
untuk layar Compose. Artinya, penerapan tema aplikasi Anda akan memiliki dua sumber tepercaya: tema berbasis View dan tema Compose. Setiap perubahan pada gaya visual Anda harus dilakukan di beberapa tempat. Setelah aplikasi Anda dimigrasikan sepenuhnya ke Compose, Anda dapat menghapus tema XML.
Untuk memigrasikan tema XML ke Compose, gunakan Material Theme Builder untuk melakukan migrasi dari tema XML ke Material 3 di Compose. Anda dapat menggunakan peran warna yang ada, seperti warna primer dan sekunder dari tema XML, dan meneruskannya ke Material Theme Builder. Tindakan ini akan membuat tema Material 3 lengkap di Compose dan menyediakan file warna dan tema yang dapat didownload untuk digunakan di aplikasi Anda.
Material Theme Builder membuat MaterialTheme
serta skema warna terang dan gelap untuk aplikasi Anda. Jika aplikasi Anda menggunakan bentuk atau tipografi kustom, migrasikan bentuk dan tipografi kustom Anda dengan menentukan Shape
dan Typography
. Setelah ditentukan, berikan informasi tersebut kepada MaterialTheme
Anda. Lihat bentuk dan tipografi untuk mempelajari lebih lanjut.
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-08-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-08-27 UTC."],[],[],null,["When you introduce Compose in an existing app, you need to migrate your themes in XML to use `MaterialTheme` for Compose screens. This means your app's theming will have two sources of truth: the View-based theme and the Compose theme. Any changes to your styling need to be made in multiple places. Once your app is fully migrated to Compose, you can remove your XML theming.\n| **Note:** For non-Material design systems, see [Custom design systems in Compose](/develop/ui/compose/designsystems/custom).\n\nTo migrate your XML themes to Compose, use the [Material Theme Builder](https://m3.material.io/theme-builder) to migrate from an XML theme to [Material 3](/develop/ui/compose/designsystems/material3#material-theming) in Compose. You can use your existing color roles, such as primary and secondary colors from your XML theme, and pass them to the Material Theme Builder. This creates a fully Material 3 theme in Compose and provides downloadable color and theme files to use in your app.\n\nMaterial Theme Builder generates a `MaterialTheme` and light and dark color schemes for your app. If your app uses custom shapes or typography, migrate your custom shapes and typography by defining a `Shape` and `Typography`, respectively. Once defined, provide that information to your `MaterialTheme`. See [shapes](/develop/ui/compose/designsystems/material3#shapes) and [typography](/develop/ui/compose/designsystems/material3#typography) to learn more.\n| **Note:** If you are not using Material 3, see [Material Design 2 in Compose](/develop/ui/compose/designsystems/material) to learn how to create a theme. See [Migrate from Material 2 to Material 3 in Compose](/develop/ui/compose/designsystems/material2-material3) when you are ready to migrate to Material 3."]]