Reputation: 73
I have items are wrapped in motionLayout and recyclerView in which need set one item to the End state, and leave the rest in the Start state without any animations or blinks, just show.
When i try call
transitionToState(endState)
or
transitionToEnd()
the animation happens, but i just need to set the element to End state the first time. And everything should be animated when the user clicks on the items
Upvotes: 5
Views: 1758
Reputation: 3501
You can seek the transition programmatically: setProgress(1f)
will transition without animation to the end state.
Upvotes: 2
Reputation: 91
You can transition to the end state of your MotionLayout without animation by doing the following:
yourMotionLayout.setTransitionDuration(0)
yourMotionLayout.transitionToEnd()
You can wrap this into an extension function for easier re-use:
/**
* Triggers the underlying [MotionLayout] to transition to end state immediately.
*/
fun MotionLayout.jumpToEnd() {
this.setTransitionDuration(0)
this.transitionToEnd()
}
Upvotes: 7