I would like my activity's Toolbar
to smoothly scroll out as a given scrollview grows, and then smoothly scroll back in if the user scrolls down. I.e. the basic scroll|enterAlways
behaviour from e.g. this answer.
However, my layout has some layers between the CoordinatorLayout
containing the Toolbar
, and the ScrollView
that should be driving everything. Unlike in this answer, I'd like to have the following layout:
CoordinatorLayout
AppBarLayout
Toolbar
LinearLayout [vertical]
LinearLayout [vertical]
ImageView
ScrollView
The seemingly redundant two LinearLayout
s are for background color control; and the idea with the ImageView
and the ScrollView
is that my UI should look like this:
+------------+
|TOOLBAR =|
+------------+
| |
| IMAGE |
| |
|111111111111|
|222222222222|
|333333333333|
|444444444444|
+------------+
which should then scroll to
+TOOLBAR----=+
+------------+
| |
| IMAGE |
| |
|111111111111|
|222222222222|
|333333333333|
|444444444444|
|555555555555|
+------------+
and further to
+------------+
| |
| IMAGE |
| |
|111111111111|
|222222222222|
|333333333333|
|444444444444|
|555555555555|
|666666666666|
+------------+
and then to
+------------+
| |
| IMAGE |
| |
|222222222222|
|333333333333|
|444444444444|
|555555555555|
|666666666666|
|777777777777|
+------------+
(with the numbers representing the things in the ScrollView
).
The above behaviour I was able to get just by setting
app:layout_scrollFlags="scroll|enterAlways"
on the Toolbar
as standard. However, if I then start dragging down on the ScrollView
, the Toolbar
doesn't come back. In fact, I haven't found any way to get the Toolbar
back once it has scrolled out.