<KeyFrameSet>
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
מציין מיקום ומאפיינים של צפיות במהלך התנועה
ברצף. כברירת מחדל, התנועה ממשיכה מהמצב הראשוני אל המצב הסופי.
בעזרת <KeyFrameSet>
, ניתן ליצור תנועות מורכבות יותר.
השדה <KeyFrameSet>
מכיל
<KeyPosition>
או
<KeyAttribute>
צמתים. הצמתים האלה מציינים את המיקום או המאפיינים של תצוגת יעד
לנקודה ספציפית בתנועה.
MotionLayout
יוצרת אנימציה חלקה של התצוגה מנקודת ההתחלה ועד לכל נקודת ביניים
ואז ליעד הסופי.
נניח שבמצב הראשוני של רצף התנועה יש כדור אטום
בפינה השמאלית התחתונה של התצוגה, והמצב הסופי הופך את הכדור לשקוף
בפינה הימנית העליונה. כברירת מחדל, MotionLayout
מניע את הכדור בצורה חלקה
בקו אלכסוני, שהופך בהדרגה לשקוף עד שהוא נעלם
מגיע ליעד. אם משתמשים ב-<KeyFrameSet>
, אפשר לשנות את ההתנהגות הזו.
לדוגמה, אפשר לגרום לכדור לנוע אנכית לפינה השמאלית העליונה
כאשר נותר אטום לחלוטין, ולאחר מכן עובר אופקית לפינה הימנית העליונה
בזמן שהם נעלמים. כדי לעשות זאת, אפשר ליצור <KeyFrameSet>
הוספה של <KeyPosition>
ו-<KeyAttribute>
בתוכו. <KeyPosition>
מציין את מיקום הביניים של הכדור וה<KeyAttribute>
מציין שהכדור נשאר אטום בנקודת האמצע של התנועה.
תחביר
<KeyFrameSet>
[ <KeyPosition/>... ]
[ <KeyAttribute/>...]
</KeyFrameSet>
בתוך
<Transition>
השירים הכלולים
<KeyPosition>
- קביעת מיקום צפייה ברגע ספציפי ברצף התנועה.
<KeyAttribute>
- קביעת מאפייני צפייה ברגע ספציפי ברצף התנועה.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. 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,["# <KeyFrameSet>\n\nSpecifies location and attributes for views over the course of the motion\nsequence. By default, motion proceeds from the initial state to the end state.\nBy using `\u003cKeyFrameSet\u003e`, you can build more complex motions.\n\nThe `\u003cKeyFrameSet\u003e` contains\n[`\u003cKeyPosition\u003e`](/training/constraint-layout/motionlayout/ref/keyposition) or\n[`\u003cKeyAttribute\u003e`](/training/constraint-layout/motionlayout/ref/keyattribute)\nnodes. These nodes specify the position or attributes of a target view at a\nspecific point in the motion.\n[`MotionLayout`](/reference/androidx/constraintlayout/motion/widget/MotionLayout)\nsmoothly animates the view from the starting point to each intermediate point\nand then to the final destination.\n\nSuppose the initial state of the motion sequence has an opaque ball in the\nlower-left corner of the view, and the final state makes the ball transparent in\nthe upper-right corner. By default, the `MotionLayout` moves the ball smoothly\nin a diagonal line, gradually becoming transparent until it vanishes when it\nreaches its destination. By using `\u003cKeyFrameSet\u003e`, you can change this behavior.\nFor example, you can make the ball move vertically to the upper-left corner\nwhile remaining entirely opaque, then move horizontally to the upper-right\ncorner while fading out. You can do this by creating a `\u003cKeyFrameSet\u003e` and\nadding a `\u003cKeyPosition\u003e` and `\u003cKeyAttribute\u003e` inside it. The `\u003cKeyPosition\u003e`\nspecifies the intermediate location of the ball, and the `\u003cKeyAttribute\u003e`\nspecifies that the ball remains opaque at the midpoint of the motion.\n\nSyntax\n------\n\n```xml\n\u003cKeyFrameSet\u003e\n [ \u003cKeyPosition/\u003e... ]\n [ \u003cKeyAttribute/\u003e...]\n\u003c/KeyFrameSet\u003e\n```\n\nContained in\n------------\n\n[`\u003cTransition\u003e`](/training/constraint-layout/motionlayout/ref/transition)\n\nContains\n--------\n\n[`\u003cKeyPosition\u003e`](/training/constraint-layout/motionlayout/ref/keyposition)\n: Specifies a view's position at a specific moment during the motion sequence.\n\n[`\u003cKeyAttribute\u003e`](/training/constraint-layout/motionlayout/ref/keyattribute)\n: Specifies view attributes at a specific moment during the motion sequence."]]