<Key Attributes>
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Chỉ định các thuộc tính của thành phần hiển thị tại một thời điểm cụ thể trong chuỗi chuyển động. Bạn
có thể sử dụng <KeyAttribute>
để đặt các thuộc tính chuẩn của thành phần hiển thị.
Giả sử độ mờ của khung hiển thị (android:alpha
) được đặt thành 0 ban đầu
<ConstraintSet>
và 1 trong trận chung kết <ConstraintSet>
. Theo mặc định, thao tác này
khung nhìn mờ dần trong toàn bộ chuỗi chuyển động. Nếu bạn muốn chế độ xem
để liên tục ẩn mặt trong 80% chuỗi chuyển động rồi mờ dần đi, thêm
một nút <KeyAttribute>
có thuộc tính motion:framePosition
được đặt thành 80 và
thuộc tính android:alpha
được đặt thành 0.
Cú pháp
<KeyAttribute
motion:motionTarget="@id/targetPath"
motion:framePosition="percentage"
[ attribute = value ]
/>
Thuộc tính
motion:motionTarget
- Xem thuộc tính có thuộc tính nào do
<KeyAttribute>
này kiểm soát.
motion:framePosition
- Số nguyên từ 1 đến 99 xác định thời điểm trong chuỗi chuyển động, khung hiển thị có
do
<KeyAttribute>
này chỉ định. Ví dụ: nếu framePosition
là 25, thì khung hiển thị có các thuộc tính được chỉ định ở một phần tư đường đi
thông qua chuỗi chuyển động.
Bạn có thể đặt các thuộc tính thành phần hiển thị sau đây. Để biết thêm thông tin về
hãy xem trang tham khảo về View
.
android:alpha
android:elevation
android:rotation
android:rotationX
android:rotationY
android:scaleX
android:scaleY
android:translationX
android:translationY
android:translationZ
android:visibility
transitionPathRotate
Có trong:
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[null,null,["Cập nhật lần gần đây nhất: 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)"]]