Migracja motywów XML do tworzenia
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Gdy wprowadzisz Compose w istniejącej aplikacji, musisz przenieść motywy z XML, aby używać MaterialTheme
na ekranach Compose. Oznacza to, że motyw aplikacji będzie miał 2 źródła informacji: motyw oparty na widokach i motyw Compose. Wszelkie zmiany w stylu trzeba wprowadzać w wielu miejscach. Gdy aplikacja zostanie w pełni przeniesiona na Compose, możesz usunąć motywy XML.
Aby przenieść motywy XML do Compose, użyj Kreatora motywów Material. Pozwoli Ci to przenieść motyw XML do Material 3 w Compose. Możesz użyć istniejących ról kolorów, takich jak kolory podstawowe i dodatkowe z motywu XML, i przekazać je do narzędzia Material Theme Builder. W ten sposób utworzysz w Compose pełny motyw Material 3 i uzyskasz pliki kolorów i motywów do pobrania, których możesz używać w aplikacji.
Narzędzie Material Theme Builder generuje MaterialTheme
oraz jasny i ciemny schemat kolorów aplikacji. Jeśli aplikacja używa niestandardowych kształtów lub typografii, przenieś je, definiując odpowiednio Shape
i Typography
. Po zdefiniowaniu tych informacji przekaż je do MaterialTheme
. Więcej informacji znajdziesz w sekcjach kształty i typografia.
Treść strony i umieszczone na niej fragmenty kodu podlegają licencjom opisanym w Licencji na treści. Java i OpenJDK są znakami towarowymi lub zastrzeżonymi znakami towarowymi należącymi do firmy Oracle lub jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-08-21 UTC.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 2025-08-21 UTC."],[],[],null,["# Migrate XML themes to Compose\n\nWhen 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."]]