<Atributo de clave>
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Especifica atributos de vista en un momento específico durante la secuencia de movimiento. Tú
Puedes usar <KeyAttribute>
para establecer los atributos estándar de la vista.
Supongamos que la opacidad de una vista (android:alpha
) está establecida en 0 en la
<ConstraintSet>
y 1 en la final de <ConstraintSet>
. De forma predeterminada,
la vista se atenúa linealmente para toda la secuencia de movimiento. Si quieres que la vista
permanezca invisible el 80% de la secuencia de movimiento
y, luego, se atenúe rápidamente.
un nodo <KeyAttribute>
con el atributo motion:framePosition
establecido en 80
el atributo android:alpha
establecido en 0.
Sintaxis
<KeyAttribute
motion:motionTarget="@id/targetPath"
motion:framePosition="percentage"
[ attribute = value ]
/>
Atributos
motion:motionTarget
- Visualiza los atributos controlados por este
<KeyAttribute>
.
motion:framePosition
- Número entero del 1 al 99 que especifica en qué momento de la secuencia de movimiento la vista tiene
atributos especificados por este
<KeyAttribute>
. Por ejemplo, si framePosition
es 25, entonces la vista tiene los atributos especificados a un cuarto del camino
a través de la secuencia de movimiento.
Puedes establecer los siguientes atributos de vista. Para obtener más información
consulta la página de referencia de View
.
android:alpha
android:elevation
android:rotation
android:rotationX
android:rotationY
android:scaleX
android:scaleY
android:translationX
android:translationY
android:translationZ
android:visibility
transitionPathRotate
Dónde se incluye
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,["# <KeyAttribute>\n\nSpecifies view attributes at a specific moment during the motion sequence. You\ncan use `\u003cKeyAttribute\u003e` to set the view's [standard attributes](/reference/android/support/constraint/motion/MotionLayout#standard-attributes).\n\nSuppose a view's opacity (`android:alpha`) is set to 0 in the initial\n`\u003cConstraintSet\u003e` and 1 in the final `\u003cConstraintSet\u003e`. By default, this makes\nthe view linearly fade in for the entire motion sequence. If you want the view\nto remain invisible for 80% of the motion sequence and then fade in quickly, add\na `\u003cKeyAttribute\u003e` node with the `motion:framePosition` attribute set to 80 and\nthe `android:alpha` attribute set to 0.\n\nSyntax\n------\n\n```xml\n\u003cKeyAttribute\n motion:motionTarget=\"@id/targetPath\"\n motion:framePosition=\"percentage\"\n [ attribute = value ]\n/\u003e\n```\n\nAttributes\n----------\n\n`motion:motionTarget`\n: View whose attributes are controlled by this `\u003cKeyAttribute\u003e`.\n\n`motion:framePosition`\n: Integer from 1 to 99 specifying when in the motion sequence the view has the\n attributes specified by this `\u003cKeyAttribute\u003e`. For example, if `framePosition`\n is 25, then the view has the specified attributes one-quarter of the way\n through the motion sequence.\n\nYou can set the following view attributes. For more information about these\nattributes, see the [`View`](/reference/android/view/View) reference page.\n\n- `android:alpha`\n- `android:elevation`\n- `android:rotation`\n- `android:rotationX`\n- `android:rotationY`\n- `android:scaleX`\n- `android:scaleY`\n- `android:translationX`\n- `android:translationY`\n- `android:translationZ`\n- `android:visibility`\n- `transitionPathRotate`\n\nContained in\n------------\n\n- [`\u003cKeyFrameSet\u003e`](/training/constraint-layout/motionlayout/ref/keyframeset)"]]