Android: CollapsingToolbarLayout and SearchView, text overlap

I have few problems overlapping the CollapsingToolbarLayout header with SearchView text. When CollapsingToolbarLayout is expanded, no problem:

enter image description here

But when minimized, the text overlaps:

enter image description here

How to fix it?

+5
source share
3 answers

I tried to reply with Thomas, but he had a problem that as soon as the user scrolls, the application bar resets again and the problem reappears.

So, I came up with another solution that should make the transparent text of the collapsed title transparent when expanding the search area . This works great and does not depend on the state to minimize / expand the application panel and does not change it.

This is simple:

if (searchViewExpanding) { collapsingToolbarLayout.setCollapsedTitleTextColor(Color.TRANSPARENT); } else { collapsingToolbarLayout.setCollapsedTitleTextColor(Color.WHITE); } 

Of course, you need to process the setOnActionExpandListener your search menu item to find out when it can be called.

+1
source

Now the answer is simple, expand CollapsingToolbarLayout at the click of a button . Thanks to TuαΊ₯n TrαΊ§n Anh and this code:

 coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinator_layout); appBarLayout = (AppBarLayout) findViewById(R.id.appbar); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams(); AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) params.getBehavior(); behavior.setTopAndBottomOffset(0); behavior.onNestedPreScroll(coordinatorLayout, appBarLayout, null, 0, 1, new int[2]); 

more information is in this thread .

+1
source

EDIT

Still not resolving this, they have another unresolved problem. With the change of text. Now the trick uses ControllableAppLayout to know when the panel collapses or expands, so you just set and setTitle ("") the header

You can find my implementation here https://gist.github.com/skimarxall/863585dcd7abde8f4153

Question: https://code.google.com/p/android/issues/detail?id=178138

-1
source

All Articles