<KeyAttribute>
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
指定运动序列中特定时刻的视图属性。您
可以使用 <KeyAttribute>
设置视图的标准属性。
假设视图的不透明度 (android:alpha
) 在初始状态下设置为 0
最后 <ConstraintSet>
分,击中三柱门 <ConstraintSet>
次。默认情况下
视图在整个运动序列中以线性方式淡入。如果您希望
即在 80% 的运动序列中保持不可见状态,然后快速淡入,添加
一个 <KeyAttribute>
节点(motion:framePosition
属性设置为 80);以及
将 android:alpha
属性设置为 0。
语法
<KeyAttribute
motion:motionTarget="@id/targetPath"
motion:framePosition="percentage"
[ attribute = value ]
/>
属性
motion:motionTarget
- 哪些视图的属性受此
<KeyAttribute>
控制。
motion:framePosition
- 从 1 到 99 的整数,用于指定视图在运动序列中的时间点
此
<KeyAttribute>
指定的属性。例如,如果 framePosition
为 25,则视图在视图的四分之一处具有指定属性
整个运动序列的过程。
您可以设置以下视图属性。如需详细了解
属性,请参阅 View
参考页面。
android:alpha
android:elevation
android:rotation
android:rotationX
android:rotationY
android:scaleX
android:scaleY
android:translationX
android:translationY
android:translationZ
android:visibility
transitionPathRotate
包含于
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],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)"]]