I'm pretty sure this is a bug, so I'm asking for a workaround. My layout is like:
<CoordinatorLayout>
<AppBarLayout>
<CollapsingToolbarLayout>
<ImageView/>
<Toolbar/>
</CollapsingToolbarLayout>
</AppBarLayout>
<android.support.v4.widget.NestedScrollView/> <!-- content here -->
</CoordinatorLayout>
I'm retrieving content from the web, and I don't know how tall it'll be - might be few lines, might be very long.
However, I discovered that CollapsingToolbar
doesn't work well when content is not big enough to cover the entire screen. Cases:
content.height > screen.height
: works; swiping top/bottom expands and collapses the toolbar, as well as scrolling content;
content.height < screen.height
: doesn't. That's not good, because most of the times (content.height + expandedToolbar.height) > screen.height
!
In other words, when content is not tall enough, even if content+expandedToolbar is much taller than the whole screen, it doesn't react to scroll gestures and shows some bugs - it might take ten gestures to collapse the toolbar a little bit. So you can hardly reach the bottom part of the content, which is hidden at the bottom because the toolbar is expanded.
Any workaround?
If you want to try, just take the cheesesquare sample project and delete (or reduce) the content inside NestedScrollView
in activity_detail.xml [API17 here]
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…