<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 มุมมองจะมีแอตทริบิวต์ที่ระบุ 1 ใน 4 ของเส้นทาง
ไปตามลำดับการเคลื่อนไหว
คุณสามารถตั้งค่าแอตทริบิวต์การแสดงผลต่อไปนี้ สำหรับข้อมูลเพิ่มเติมเกี่ยวกับ
โปรดดูหน้าข้อมูลอ้างอิง 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 UTC
[null,null,["อัปเดตล่าสุด 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)"]]