I have little problem with overlapping CollapsingToolbarLayout title with SearchView text. When is CollapsingToolbarLayout expanded, there is no problem:
But when is collapsed, the text is overlapped:
How to fix it?
I tried the answer by Tomas, but it had a problem that as soon as the user scrolls, the appbar collapses again and the problem re-appears.
So I came up with another solution which is to make the collapsed title text transparent when the searchview is expanded. This works nicely and does not depend on or change the collapse/expand state of the appbar.
Simply this:
if (searchViewExpanding) {
collapsingToolbarLayout.setCollapsedTitleTextColor(Color.TRANSPARENT);
} else {
collapsingToolbarLayout.setCollapsedTitleTextColor(Color.WHITE);
}
Of course, you'll need to handle setOnActionExpandListener
of your search menu item to know when to call this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With