When launched on Nougat, why does the header turn off when using CollapsingToolbarLayout?

I use the following layout and it works great on all versions except Android Nougat, where the title is cropped when it completely crashes.

enter image description here

<android.support.design.widget.CollapsingToolbarLayout android:id="@+id/collapsing_toolbar" android:layout_width="match_parent" android:layout_height="300dp" android:fitsSystemWindows="true" app:contentScrim="@color/them_color" app:expandedTitleTextAppearance="@android:color/transparent" app:layout_scrollFlags="scroll|exitUntilCollapsed"> <ImageView android:id="@+id/header_image" android:layout_width="match_parent" android:layout_height="300dp" android:contentDescription="@string/app_name" android:fitsSystemWindows="true" android:scaleType="fitXY" app:layout_collapseMode="parallax"/> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?android:attr/actionBarSize" app:layout_collapseMode="pin" app:contentInsetLeft="0dp" app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> </android.support.design.widget.CollapsingToolbarLayout> 

I tried app:collapsedTitleGravity="center" , but this does not fix the problem. How can I get him to work on Nougat?

+6
source share
4 answers

The problem reported .

There is even a better option than removing fitsSystemWindows , just add to onCreate collapsingToolbarLayout.post { collapsingToolbarLayout.requestLayout() }

+7
source

Android removal: fitsSystemWindows = "true" solved my problem

+3
source

Yes, it is annoying.

I came here to solve the problem, so I have no solution, but all I can say is if you switch to the split screen and back, the problem will disappear.

Perhaps this fact may help someone closer to the solution.

Edit: just remove fitsSystemWindows from AppBarLayout; it did it for me.

+1
source

This sample project shows how to implement a minimized toolbar in Android.

+1
source

Source: https://habr.com/ru/post/1015281/


All Articles