<KeyFrameSet>
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Gibt die Position und Attribute für Ansichten im Verlauf der Bewegung an.
Sequenz hinzufügen. In der Standardeinstellung verläuft die Bewegung vom Anfangs- in den Endzustand.
Mit <KeyFrameSet>
können Sie komplexere Bewegungen erstellen.
<KeyFrameSet>
enthält
<KeyPosition>
oder
<KeyAttribute>
Knoten. Diese Knoten geben die Position oder Attribute einer Zielansicht an einem
bestimmten Punkt in der Bewegung.
MotionLayout
animiert die Ansicht gleitend vom Startpunkt zu jedem Zwischenpunkt.
und dann zum Ziel.
Nehmen wir an, im Anfangszustand der Bewegungsabfolge wäre im Bereich der Bewegungsabfolge
in der unteren linken Ecke der Ansicht. Durch den Endzustand wird der Ball in der Ansicht transparent
in der oberen rechten Ecke. Standardmäßig bewegt MotionLayout
den Ball gleichmäßig
in einer diagonalen Linie, die allmählich transparent wird, bis sie verschwindet.
das Ziel erreicht. Mit <KeyFrameSet>
können Sie dieses Verhalten ändern.
Sie können den Ball zum Beispiel vertikal nach oben links bewegen.
vollständig undurchsichtig und dann horizontal nach oben rechts
beim Ausblenden. Erstellen Sie dazu eine <KeyFrameSet>
und
<KeyPosition>
und <KeyAttribute>
werden darin eingefügt. Das <KeyPosition>
gibt die Zwischenposition des Balls an und der <KeyAttribute>
gibt an, dass der Ball beim Mittelpunkt der Bewegung undurchsichtig bleibt.
Syntax
<KeyFrameSet>
[ <KeyPosition/>... ]
[ <KeyAttribute/>...]
</KeyFrameSet>
Enthalten in
<Transition>
Enthält
<KeyPosition>
- Gibt die Position einer Ansicht zu einem bestimmten Zeitpunkt während der Bewegungsabfolge an.
<KeyAttribute>
- Gibt Ansichtsattribute zu einem bestimmten Zeitpunkt während der Bewegungsabfolge an.
Alle Inhalte und Codebeispiele auf dieser Seite unterliegen den Lizenzen wie im Abschnitt Inhaltslizenz beschrieben. Java und OpenJDK sind Marken oder eingetragene Marken von Oracle und/oder seinen Tochtergesellschaften.
Zuletzt aktualisiert: 2025-07-27 (UTC).
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 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."]]