Setfitsystemwindows does not work windowtranslucentstatus coordinatorlayout

I am working on a small Android project. I'm having trouble displaying the toolbar below the status bar. I am using the following configuration:

  • Library support version 23.2.0
  • windowTranslucentStatus = true

<CollapsingToolbarLayout fitSystemWindows="true" ...> <FrameLayout fitSystemWindows="true" ...> <ViewPager> ....consists a fragment with framelayout and image </ViewPager> <Toolbar fitSystemWindows="true" ...> </FrameLayout> <CollapsingToolbarLayout fitSystemWindows="true"...> ..... </AppBarLayout> </CoordinatorLayout>` 

Image is displayed correctly but not the toolbar

 <android.support.design.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:fitsSystemWindows="true"> <android.support.design.widget.AppBarLayout android:id="@+id/fragment_musicplayer_appBarlayout_test" android:layout_width="match_parent" android:layout_height="wrap_content" android:fitsSystemWindows="true"> <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/fragment_musicexplorer_album_collapsingtoolbarlayout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" app:contentScrim="#eab22b" app:expandedTitleMarginStart="48dp" app:expandedTitleMarginEnd="64dp" app:layout_scrollFlags="scroll|exitUntilCollapsed"> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_collapseMode="parallax" android:fitsSystemWindows="true"> <android.support.v4.view.ViewPager android:id="@+id/fragment_musicplayer_viewpager_test" android:layout_width="match_parent" android:layout_height="450dp" /> <android.support.v7.widget.Toolbar android:id="@+id/fragment_musicplayer_toolbar_test" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="@android:color/transparent" android:fitsSystemWindows="true" /> </FrameLayout> </android.support.design.widget.CollapsingToolbarLayout> 
+5
source share
1 answer

If you change the android:fitsSystemWindows="true" to android:fitsSystemWindows="false" , it may work.

I ran into a similar problem with your version of Support library version 23.2.0 , and then looked at StackOverflow; found your question.

My case was the opposite of yours, because I did not need the interval of the upper edge, but it was. Although I set android:fitsSystemWindows="false" , but nothing has changed.

But I found that you set windowTranslucentStatus = true , and so did I. This is the key.

I decided to change android:fitsSystemWindows="false" to android:fitsSystemWindows="true" . It worked.

It is possible that the behavior of android:fitsSystemWindows been changed. It may have been inverted when windowTranslucentStatus = true .

β€œBut the problem remains.” When the toolbar is collapsed, the bottom border of the toolbar is still misaligned. I have to abandon the use of windowTranslucentStatus = true ...

EDIT : 23.2.1 was released and the problem with the lower border was fixed. But the above assumption that the behavior of android:fitsSystemWindows been inverted remains true.

0
source

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


All Articles