汤姆如何链接几个转换?
How tom chain several transitions?
热衷于在 motionlayout 中一个接一个地播放过渡,使其看起来像单个动画?虽然关键帧可用于在两个约束集之间建立中间状态,但它们也受到限制,无法修改所有需要的属性。
<Transition
app:constraintSetEnd="@layout/simple_start"
app:constraintSetStart="@layout/simple_middle"
>
<OnSwipe
app:dragDirection="dragUp"
app:touchAnchorId="@id/scrollable"
app:touchAnchorSide="top" />
</Transition>
<Transition
app:constraintSetEnd="@layout/simple_middle"
app:constraintSetStart="@layout/simple_end"
>
<OnSwipe
app:dragDirection="dragUp"
app:touchAnchorId="@id/scrollable"
app:touchAnchorSide="top" />
</Transition>
</MotionScene>
您是否尝试过直接在您的代码中启动转换?
((MotionLayout)findViewById(R.id.simple_start)).transitionToEnd();
((MotionLayout)findViewById(R.id.simple_middle)).transitionToEnd();
override fun onClick(v: View) {
when (v.id) {
R.id.likeView -> {
motionLayout.setTransition(R.id.start_first_set,R.id.end_first_set)
motionLayout.transitionToEnd() // start first anime
}
}
motionLayout.setTransitionListener(object : MotionLayout.TransitionListener{
// .....
override fun onTransitionCompleted(p0: MotionLayout?, id: Int) {
when (id) {
R.id.end_first_set -> {
motionLayout.setTransition(R.id.start_second_set,R.id.end_secons_set)
motionLayout.transitionToEnd() // start second anime
}
}
})
热衷于在 motionlayout 中一个接一个地播放过渡,使其看起来像单个动画?虽然关键帧可用于在两个约束集之间建立中间状态,但它们也受到限制,无法修改所有需要的属性。
<Transition
app:constraintSetEnd="@layout/simple_start"
app:constraintSetStart="@layout/simple_middle"
>
<OnSwipe
app:dragDirection="dragUp"
app:touchAnchorId="@id/scrollable"
app:touchAnchorSide="top" />
</Transition>
<Transition
app:constraintSetEnd="@layout/simple_middle"
app:constraintSetStart="@layout/simple_end"
>
<OnSwipe
app:dragDirection="dragUp"
app:touchAnchorId="@id/scrollable"
app:touchAnchorSide="top" />
</Transition>
</MotionScene>
您是否尝试过直接在您的代码中启动转换?
((MotionLayout)findViewById(R.id.simple_start)).transitionToEnd();
((MotionLayout)findViewById(R.id.simple_middle)).transitionToEnd();
override fun onClick(v: View) {
when (v.id) {
R.id.likeView -> {
motionLayout.setTransition(R.id.start_first_set,R.id.end_first_set)
motionLayout.transitionToEnd() // start first anime
}
}
motionLayout.setTransitionListener(object : MotionLayout.TransitionListener{
// .....
override fun onTransitionCompleted(p0: MotionLayout?, id: Int) {
when (id) {
R.id.end_first_set -> {
motionLayout.setTransition(R.id.start_second_set,R.id.end_secons_set)
motionLayout.transitionToEnd() // start second anime
}
}
})