סידור רכיבים בקבוצות
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
קבוצות מאפשרות לכם להפריד את העיצוב של תצוגת השעון למבנה לוגי.
כך תוכלו לארגן את הרכיבים. אפשר לתת לכל קבוצה name
כדי לציין למה היא מיועדת.
סיבה נוספת לכך שקבוצות הן שימושיות מאוד היא שאפשר להתייחס לכל מה שנמצא בקבוצה הזו כישות אחת, כדי לשנות את המראה שלה, ואפילו לשנות אותה באופן דינמי בהתאם לשינויים במקור הנתונים.
ריכזנו כאן כמה דוגמאות לשימוש שימושי באפשרות הזו. ה-Group
הבא מכיל אלמנטים שונים של PartText, PartImage
ו-PartDraw
שמרכיבים חלק לוגי אחד של לוח השעון:
<Group name="decorations" ...>
<PartText ...>
<PartImage ...>
<PartDraw ...>
</Group>
שינוי ההתנהגות במצב אווירה
אחרי שמגדירים את Group
, אפשר לשנות את ההצגה של כל Group
במצב רגיש לסביבה. לדוגמה, כדי להסתיר את Group
:
<Group ...>
<Variant mode="AMBIENT" target="alpha" value="0" />
<PartText ...>
<PartImage ...>
<PartDraw ...>
</Group>
כך לא תצטרכו להוסיף אלמנט Variant
בנפרד לכל רכיב צאצא.
בדומה לשינוי ההתנהגות בסביבה, אפשר לשנות הרבה מהמאפיינים של Group
באמצעות רכיב Transform
אחד או יותר, באמצעות Variant
.
בדוגמה הזו, ה-Group
מסתובב על סמך השנייה. כשמציינים את pivotX
ו-pivotY
בתור 0.5
, הסיבוב מתרחש סביב מרכז ה-Group
, ללא קשר למיקום של כל רכיב, כמו PartText
או PartImage
בתוך ה-Group
:
<Group x="0" y="0" width="450" height="450" pivotX="0.5" pivotY="0.5">
<!-- One full rotation per minute -->
<Transform target="angle" value="[SECOND] * 6" />
<PartText ...>
<PartImage ...>
<PartDraw ...>
</Group>
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. 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,["# Arrange elements into groups\n\nGroups allow you to separate your watch face design into a logical structure.\n\nThis can be useful to help you organize components. You can give each\ngroup a `name` to indicate what it is for.\n\nA further reason that groups are very useful is that you can then treat\neverything within that group as a single entity for the purpose of adjusting its\nappearance, even dynamically adjusting to changing data sources.\n\nHere are some examples of how this can be useful. The following `Group` contains\nvarious `PartText, PartImage` and `PartDraw` elements that make up a single\nlogical part of the watch face: \n\n \u003cGroup name=\"decorations\" ...\u003e\n \u003cPartText ...\u003e\n \u003cPartImage ...\u003e\n \u003cPartDraw ...\u003e\n \u003c/Group\u003e\n\nChange ambient behavior\n-----------------------\n\nHaving defined the `Group`, the visibility of the whole `Group` can be adjusted\nfor Ambient mode, for example, to hide the `Group`: \n\n \u003cGroup ...\u003e\n \u003cVariant mode=\"AMBIENT\" target=\"alpha\" value=\"0\" /\u003e\n \u003cPartText ...\u003e\n \u003cPartImage ...\u003e\n \u003cPartDraw ...\u003e\n \u003c/Group\u003e\n\nThis avoids the need to add a `Variant` element individually to each child\nelement.\n\n### Transform a group\n\nSimilar to adjusting the ambient behavior, using `Variant`, many of the\nproperties of `Group` can be adjusted using one or more `Transform` elements.\n\nIn this example, the `Group` is rotated based on the second. By specifying\n`pivotX` and `pivotY` as `0.5`, the rotation occurs around the center of the\n`Group`, irrespective of where each element, such as `PartText` or `PartImage`\nsits within that `Group`: \n\n \u003cGroup x=\"0\" y=\"0\" width=\"450\" height=\"450\" pivotX=\"0.5\" pivotY=\"0.5\"\u003e\n \u003c!-- One full rotation per minute --\u003e\n \u003cTransform target=\"angle\" value=\"[SECOND] * 6\" /\u003e\n \u003cPartText ...\u003e\n \u003cPartImage ...\u003e\n \u003cPartDraw ...\u003e\n \u003c/Group\u003e"]]