העברת עיצובי XML לכתיבה
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
כשמשלבים את Compose באפליקציה קיימת, צריך להעביר את העיצובים ב-XML כדי להשתמש ב-MaterialTheme
למסכי Compose. המשמעות היא שיהיו שני מקורות אמת לעיצוב האפליקציה: העיצוב מבוסס-התצוגה והעיצוב של Compose. כל שינוי בסגנון צריך להתבצע בכמה מקומות. אחרי שהאפליקציה תעבור מיגרציה מלאה ל-Compose, תוכלו להסיר את העיצוב של ה-XML.
כדי להעביר את העיצובים ב-XML ל-Compose, משתמשים בכלי העיצוב של Material כדי להעביר עיצוב ב-XML ל-Material 3 ב-Compose. אתם יכולים להשתמש בתפקידי הצבעים הקיימים, כמו צבעים ראשיים ומשניים מתוך עיצוב ה-XML, ולהעביר אותם אל הכלי ליצירת עיצוב Material. הפעולה הזו יוצרת עיצוב מלא של Material 3 ב-Compose ומספקת קובצי צבעים ועיצובים להורדה שאפשר להשתמש בהם באפליקציה.
כלי העיצוב של Material יוצר MaterialTheme
וערכות צבעים בהירות וכהות לאפליקציה. אם האפליקציה משתמשת בצורות או בטיפוגרפיה בהתאמה אישית, צריך להגדיר Shape
ו-Typography
כדי להעביר את הצורות והטיפוגרפיה המותאמות אישית. אחרי שמגדירים את המידע הזה, מעבירים אותו אל MaterialTheme
. מידע נוסף זמין במאמרים בנושא צורות וטיפוגרפיה.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-08-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-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."]]