<KeyAttribute>
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
指定動作序列中特定時刻的檢視屬性。個人中心
可以使用 <KeyAttribute>
設定檢視畫面的標準屬性。
假設檢視畫面的不透明度 (android:alpha
) 在初始值設為 0
<ConstraintSet>
和 1 在最終<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 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[null,null,["上次更新時間: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)"]]