<Набор ключевых кадров>
Оптимизируйте свои подборки
Сохраняйте и классифицируйте контент в соответствии со своими настройками.
Указывает местоположение и атрибуты для видов в ходе последовательности движений. По умолчанию движение продолжается от начального состояния к конечному состоянию. Используя <KeyFrameSet>
, вы можете создавать более сложные движения.
<KeyFrameSet>
содержит узлы <KeyPosition>
или <KeyAttribute>
. Эти узлы определяют положение или атрибуты целевого вида в определенной точке движения. MotionLayout
плавно анимирует вид от начальной точки до каждой промежуточной точки, а затем до конечного пункта назначения.
Предположим, что в начальном состоянии последовательности движений есть непрозрачный шар в левом нижнем углу изображения, а в конечном состоянии шар становится прозрачным в правом верхнем углу. По умолчанию MotionLayout
плавно перемещает мяч по диагональной линии, постепенно становясь прозрачным, пока не исчезнет, когда достигнет места назначения. Используя <KeyFrameSet>
, вы можете изменить это поведение. Например, вы можете заставить шар двигаться вертикально в верхний левый угол, оставаясь при этом полностью непрозрачным, а затем перемещаться горизонтально в верхний правый угол, постепенно исчезая. Это можно сделать, создав <KeyFrameSet>
и добавив в него <KeyPosition>
и <KeyAttribute>
. <KeyPosition>
указывает промежуточное положение мяча, а <KeyAttribute>
указывает, что мяч остается непрозрачным в средней точке движения.
Синтаксис
<KeyFrameSet>
[ <KeyPosition/>... ]
[ <KeyAttribute/>...]
</KeyFrameSet>
Содержится в
<Transition>
Содержит
-
<KeyPosition>
- Указывает положение вида в определенный момент последовательности движений.
-
<KeyAttribute>
- Определяет атрибуты просмотра в определенный момент последовательности движений.
Контент и образцы кода на этой странице предоставлены по лицензиям. Java и OpenJDK – это зарегистрированные товарные знаки корпорации Oracle и ее аффилированных лиц.
Последнее обновление: 2025-07-29 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-29 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."]]