“Hidden” Toolbar visible under status bar

删除回忆录丶 提交于 2019-12-06 04:46:36

问题


Using the CoordinatorLayout to hide my toolbar when scrolling down.

The toolbar thinks it's hidden - But it's not.

Does anyone understand why this is happening?

Note: I have the status bar set to translucent to have proper material drawers. Making the status bar a solid color is not the solution I'm looking for - Unless of course that is how this was intended to be used.


回答1:


I try to set statusbar color as the primarydark, then statusbar can not be transparent when drawer is opened otherwise toolbar comes out again. After two days work, I found that if I remove the android:fitsSystemWindows="true" in my CoordinatorLayout, it solved.

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<-- CoordinatorLayout is root of @layout/app_bar_home-->
<include
    layout="@layout/app_bar_home"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"

    app:headerLayout="@layout/nav_header_home"
    app:menu="@menu/activity_home_drawer" />




回答2:


Not exactly sure what I was doing wrong but I was able to resolve this by following these examples:

https://github.com/chrisbanes/cheesesquare/blob/master/app/src/main/res/layout/activity_detail.xml

https://github.com/chrisbanes/cheesesquare/blob/f9eb39d29ea057b56e270263fa26f76e0bf3e77a/app/src/main/res/layout/include_list_viewpager.xml



来源:https://stackoverflow.com/questions/33164337/hidden-toolbar-visible-under-status-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!