<ConstraintSet
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
指定所有视图在运动中某一点的位置和属性
序列。通常情况下,
<Transition>
元素指向两个 <ConstraintSet>
元素,其中一个用于定义
一个运动序列,另一个定义结束。
语法
<ConstraintSet
id="@id/name">
[ deriveConstraintsFrom="id" ]
...
</ConstraintSet>
属性
deriveConstraintsFrom
- (可选)另一个
ConstraintSet
的 ID。如果指定,则所有限制条件
会应用于此ConstraintSet
,除非这个集合
会替换它们。
android:id
- 此约束条件集的唯一标识符。
<Transition>
需要此 ID 才能
确定运动序列的起点和终点。
必须包含
包含于
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# <ConstraintSet>\n\nSpecifies the positions and attributes of all views at one point in a motion\nsequence. Typically, a\n[`\u003cTransition\u003e`](/training/constraint-layout/motionlayout/ref/transition)\nelement points to two `\u003cConstraintSet\u003e` elements, one defining the beginning of\nthe motion sequence and one defining the end.\n\nSyntax\n------\n\n```xml\n\u003cConstraintSet\n id=\"@id/name\"\u003e\n [ deriveConstraintsFrom=\"id\" ]\n ...\n\u003c/ConstraintSet\u003e\n```\n\nAttributes\n----------\n\n`deriveConstraintsFrom`\n: *(optional)* The ID of another `ConstraintSet`. If specified, all constraints\n from that set are applied to this `ConstraintSet`, unless this set specifically\n overrides them.\n\n`android:id`\n: Unique identifier for this constraint set. The `\u003cTransition\u003e` needs this ID to\n identify the start and end points of the motion sequence.\n\nMust contain\n------------\n\n- One or more [`\u003cConstraint\u003e`](/training/constraint-layout/motionlayout/ref/constraint) elements.\n\nContained in\n------------\n\n- [`\u003cMotionScene\u003e`](/training/constraint-layout/motionlayout/ref/motionscene)"]]