尽管有 framepostion,Motion Layout 的 KeyAttribute 会立即触发
Motion Layout's KeyAttribute triggers immediately despite framepostion
我的转变:
<Transition
app:constraintSetEnd="@+id/end"
app:constraintSetStart="@+id/start"
app:motionInterpolator="linear">
<KeyFrameSet>
<KeyAttribute
app:framePosition="80"
app:motionTarget="@id/toolbar">
<CustomAttribute
app:attributeName="visibility"
app:customIntegerValue="8" />
</KeyAttribute>
<KeyAttribute
app:framePosition="80"
app:motionTarget="@id/navHostFragment">
<CustomAttribute
app:attributeName="visibility"
app:customIntegerValue="8" />
</KeyAttribute>
<KeyAttribute
app:framePosition="80"
app:motionTarget="@id/playerStatus">
<CustomAttribute
app:attributeName="visibility"
app:customIntegerValue="8" />
</KeyAttribute>
</KeyFrameSet>
<OnSwipe
app:dragDirection="dragUp"
app:touchRegionId="@id/mlView" />
</Transition>
无论我在 frameposition 中使用什么数字,keyattribute 的可见性都会在动画开始时立即应用。为什么?
将 framePosition="0"
的 <KeyAttribute>
添加到布局的默认值。由于没有关于您的基本值的信息,可能是这样的:
<KeyFrameSet>
<KeyAttribute
app:framePosition="0"
app:motionTarget="@id/toolbar">
<CustomAttribute
app:attributeName="visibility"
app:customIntegerValue="0" />
</KeyAttribute>
<KeyAttribute
app:framePosition="0"
app:motionTarget="@id/navHostFragment">
<CustomAttribute
app:attributeName="visibility"
app:customIntegerValue="0" />
</KeyAttribute>
<KeyAttribute
app:framePosition="0"
app:motionTarget="@id/playerStatus">
<CustomAttribute
app:attributeName="visibility"
app:customIntegerValue="0" />
</KeyAttribute>
</KeyFrameSet>
这将使目标 View
保持可见直到第 79 帧,之后在过渡的第 80 帧它们将消失。
我的转变:
<Transition
app:constraintSetEnd="@+id/end"
app:constraintSetStart="@+id/start"
app:motionInterpolator="linear">
<KeyFrameSet>
<KeyAttribute
app:framePosition="80"
app:motionTarget="@id/toolbar">
<CustomAttribute
app:attributeName="visibility"
app:customIntegerValue="8" />
</KeyAttribute>
<KeyAttribute
app:framePosition="80"
app:motionTarget="@id/navHostFragment">
<CustomAttribute
app:attributeName="visibility"
app:customIntegerValue="8" />
</KeyAttribute>
<KeyAttribute
app:framePosition="80"
app:motionTarget="@id/playerStatus">
<CustomAttribute
app:attributeName="visibility"
app:customIntegerValue="8" />
</KeyAttribute>
</KeyFrameSet>
<OnSwipe
app:dragDirection="dragUp"
app:touchRegionId="@id/mlView" />
</Transition>
无论我在 frameposition 中使用什么数字,keyattribute 的可见性都会在动画开始时立即应用。为什么?
将 framePosition="0"
的 <KeyAttribute>
添加到布局的默认值。由于没有关于您的基本值的信息,可能是这样的:
<KeyFrameSet>
<KeyAttribute
app:framePosition="0"
app:motionTarget="@id/toolbar">
<CustomAttribute
app:attributeName="visibility"
app:customIntegerValue="0" />
</KeyAttribute>
<KeyAttribute
app:framePosition="0"
app:motionTarget="@id/navHostFragment">
<CustomAttribute
app:attributeName="visibility"
app:customIntegerValue="0" />
</KeyAttribute>
<KeyAttribute
app:framePosition="0"
app:motionTarget="@id/playerStatus">
<CustomAttribute
app:attributeName="visibility"
app:customIntegerValue="0" />
</KeyAttribute>
</KeyFrameSet>
这将使目标 View
保持可见直到第 79 帧,之后在过渡的第 80 帧它们将消失。