<KeyFrameSet>
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Especifica la ubicación y los atributos de las vistas en el transcurso del movimiento.
secuencia. De forma predeterminada, el movimiento pasa del estado inicial al estado final.
Si usas <KeyFrameSet>
, puedes crear movimientos más complejos.
El <KeyFrameSet>
contiene
<KeyPosition>
o
<KeyAttribute>
nodos. Estos nodos especifican la posición o los atributos de una vista de destino en una
punto específico del movimiento.
MotionLayout
anima suavemente la vista desde el punto de partida hasta cada punto intermedio
y, luego, hasta el destino final.
Supongamos que el estado inicial de la secuencia de movimiento tiene una bola opaca en la
en la esquina inferior izquierda de la vista.
El estado final hace que la bola sea transparente en
la esquina superior derecha. De forma predeterminada, MotionLayout
mueve la pelota suavemente.
en una línea diagonal, que se vuelve transparente
paulatinamente hasta que desaparezca
llegue a su destino. Si usas <KeyFrameSet>
, puedes cambiar este comportamiento.
Por ejemplo, puedes hacer que la pelota se mueva verticalmente a la esquina superior izquierda.
permaneciendo totalmente opaco, luego se mueve horizontalmente hacia la parte superior derecha
en la esquina superior
mientras se desvanece. Para ello, crea un <KeyFrameSet>
y
agregando un <KeyPosition>
y un <KeyAttribute>
dentro de él. El <KeyPosition>
especifica la ubicación intermedia de la pelota y la <KeyAttribute>
especifica que la bola permanece opaca en el punto medio del movimiento.
Sintaxis
<KeyFrameSet>
[ <KeyPosition/>... ]
[ <KeyAttribute/>...]
</KeyFrameSet>
Dónde se incluye
<Transition>
Contenido
<KeyPosition>
- Especifica la posición de una vista en un momento específico durante la secuencia de movimiento.
<KeyAttribute>
- Especifica los atributos de vista en un momento específico durante la secuencia de movimiento.
El contenido y las muestras de código que aparecen en esta página están sujetas a las licencias que se describen en la Licencia de Contenido. Java y OpenJDK son marcas registradas de Oracle o sus afiliados.
Última actualización: 2025-07-27 (UTC)
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Falta la información que necesito","missingTheInformationINeed","thumb-down"],["Muy complicado o demasiados pasos","tooComplicatedTooManySteps","thumb-down"],["Desactualizado","outOfDate","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Problema con las muestras o los códigos","samplesCodeIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 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."]]