<MotionScene>
Оптимизируйте свои подборки
Сохраняйте и классифицируйте контент в соответствии со своими настройками.
Корневой элемент файла сцены движения. <MotionScene>
содержит один или несколько элементов <Transition>
, каждый из которых определяет начальное и конечное состояние последовательности движений, а также переход между ними.
Синтаксис
<MotionScene xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
...
</MotionScene>
Должен содержать
-
<Transition>
- Указывает последовательность движений для выполнения. Если
<MotionScene>
содержит несколько элементов <Transition>
, MotionLayout
выбирает наиболее подходящий <Transition>
на основе взаимодействия пользователя. Например, <MotionScene>
может иметь четыре дочерних элемента <Transition>
, каждый из которых имеет <OnSwipe>
для перемещения пользователя в другом направлении. Когда пользователь проводит пальцем по экрану, MotionLayout
использует соответствующий <Transition>
для проведения пальцем в этом направлении.
Может содержать
-
<ConstraintSet>
- Указывает начальное или конечное состояние для одного или нескольких узлов
<Transition>
. <MotionLayout>
не может иметь дочерних элементов <ConstraintSet>
, поскольку <Transition>
может указывать на макеты XML, а не на наборы ограничений.
Атрибуты
-
defaultDuration
- Длительность по умолчанию для всех переходов в миллисекундах. Длительность по умолчанию используется для последовательностей движений, для которых не указана собственная продолжительность. Например, если вы установите
defaultDuration="300"
, все последовательности движений по умолчанию будут иметь продолжительность 300 миллисекунд, если для них явно не указана собственная продолжительность.
Контент и образцы кода на этой странице предоставлены по лицензиям. Java и OpenJDK – это зарегистрированные товарные знаки корпорации Oracle и ее аффилированных лиц.
Последнее обновление: 2025-07-29 UTC.
[[["Прост для понимания","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"]],["Последнее обновление: 2025-07-29 UTC."],[],[],null,["# <MotionScene>\n\nRoot element of a motion scene file. The `\u003cMotionScene\u003e` contains one or more\n[`\u003cTransition\u003e`](/training/constraint-layout/motionlayout/ref/transition)\nelements, each of which defines the start and end state of a motion sequence and\nthe transition between the two.\n\nSyntax\n------\n\n```xml\n\u003cMotionScene xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\u003e\n ...\n\u003c/MotionScene\u003e\n```\n\nMust contain\n------------\n\n`\u003cTransition\u003e`\n: Specifies the motion sequence to perform. If the `\u003cMotionScene\u003e` contains\n multiple `\u003cTransition\u003e` elements, the `MotionLayout` chooses the most\n appropriate `\u003cTransition\u003e` based on the user's interaction. For example, a\n `\u003cMotionScene\u003e` might have four `\u003cTransition\u003e` children, each with an\n [`\u003cOnSwipe\u003e`](/training/constraint-layout/motionlayout/ref/onswipe) for a user\n swipe in a different direction. When the user swipes on the screen, the\n `MotionLayout` uses the appropriate `\u003cTransition\u003e` for a swipe in that\n direction.\n\nCan contain\n-----------\n\n[`\u003cConstraintSet\u003e`](/training/constraint-layout/motionlayout/ref/constraintset)\n: Specifies a beginning or ending state for one or more of the `\u003cTransition\u003e`\n nodes. The `\u003cMotionLayout\u003e` is not permitted to have `\u003cConstraintSet\u003e`\n children, since the `\u003cTransition\u003e` can point to XML layouts instead of\n pointing to constraint sets.\n\nAttributes\n----------\n\n`defaultDuration`\n: Default duration for all transitions in milliseconds. The default duration is\n used for motion sequences that don't specify their own duration. For example,\n if you set `defaultDuration=\"300\"`, all motion sequences default to 300\n milliseconds in length if they don't explicitly specify their own duration."]]