View hierarchy:
[0/6] View (first view in layout)
...
[2/6] RecyclerView
...
RecyclerView's children views
...
[6/6] View (point of interest, on top)
Goal:
I need to slide in (using fast-out-slow-in interpolator)
last View (which happens to be custom toolbar) in my hierarchy when RecyclerView is scrolled suffiently high and slide it out when RecyclerView is suffiently low. Effect similar to
sliding title header at https://material.io/.
Problem:
Toolbar's animations - (view is initially hidden) to show:
title_bar.animate()
.setInterpolator(FastOutSlowInInterpolator())
.setDuration(500)
.setStartDelay(0)
.translationY(0f)
.start()
and hide it:
title_bar.animate()
.setInterpolator(FastOutSlowInInterpolator())
.setDuration(500)
.setStartDelay(0)
.translationY(someValue)
.start()
The problem is that animations won't run until RecyclerView's scrolling stops (key-up).
I suspect animations are queued in FIFO somehow and pending until scrolling stops. I don't understand why that may be the case since two views are completely independent and RecyclerView is below my Toolbar.
The Twist
This works perfectly fine:
title_bar.animate()
.setInterpolator(FastOutSlowInInterpolator())
.setDuration(0) // <-- duration is zero
.setStartDelay(0)
.translationY(someValue)
.start()
i.e. animation is fired right away (maybe it's equivalent to title_bar.translationY = someValue?)
So, what is happening here exactly?