จัดเรียงองค์ประกอบเป็นกลุ่ม
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
กลุ่มช่วยให้คุณแยกการออกแบบหน้าปัดออกเป็นโครงสร้างเชิงตรรกะได้
ซึ่งจะเป็นประโยชน์ในการช่วยจัดระเบียบคอมโพเนนต์ คุณสามารถใส่ 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
ทีละรายการในองค์ประกอบย่อยแต่ละรายการ
การปรับVariant
จะคล้ายกับการปรับลักษณะการทำงานแบบแอมเบียนท์ โดยคุณปรับพร็อพเพอร์ตี้หลายอย่างของ Group
ได้โดยใช้องค์ประกอบ Transform
อย่างน้อย 1 รายการ
ในตัวอย่างนี้ 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"]]