简体   繁体   English

设置layout_scrollFlags时,Android工具栏不会隐藏

[英]Android toolbar doesn't hide when set layout_scrollFlags

I am test android.support.design library,but I have this problem.Please look at follow pictures first. 我是测试android.support.design库,但我有这个问题。请先看下面的图片。

click the link view the picture: 点击链接查看图片: 滚动状态图像

click the link view the picture: 点击链接查看图片: 不滚动状态图像

You can see it,the toolbar doesn't hide at the back of the status bar.My layout is follow: 你可以看到,工具栏没有隐藏在状态栏的后面。我的布局如下:

<android.support.design.widget.CoordinatorLayout    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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".SettingActivity">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        android:fitsSystemWindows="true"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

    <android.support.design.widget.TabLayout
        android:id="@+id/tab_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>

<android.support.v7.widget.RecyclerView
    android:id="@+id/list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/action_btn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="10dp"
    android:src="@android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>

Can anybody give me some suggestion? 有人能给我一些建议吗?

Finally, I solve the problem. 最后,我解决了这个问题。 My material test project is create base on the Android Studio IDE default settings. 我的材料测试项目是基于Android Studio IDE默认设置创建的。 So I check the values-v21/styles.xml file. 所以我检查了values-v21 / styles.xml文件。 It has a default item <item name="android:statusBarColor">@android:color/transparent</item> . 它有一个默认项<item name="android:statusBarColor">@android:color/transparent</item> It works fine after I delete the item. 删除项目后,它工作正常。

Try doing following changes: 尝试进行以下更改:

1) Remove android:fitsSystemWindows="true" from coordinator layout. 1)从协调器布局中删除android:fitsSystemWindows="true"

2) Cut android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" from AppBarLayout and paste it inside Toolbar 2)从AppBarLayout剪切android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"并将其粘贴到Toolbar

@user5549139 I had the same problem. @ user5549139我遇到了同样的问题。 You shouldn't have deleted 你不应该删除

<item name="android:statusBarColor">@android:color/transparent</item>

It gives you transparent statusBar wchich is coherent with material design. 它为您提供透明状态,与材料设计保持一致。

My problem was that CordinatorLayout with android:fitsSystemWindows="true" was included as a child into DrawerLayout which also had android:fitsSystemWindows="true" . 我的问题是, CordinatorLayoutandroid:fitsSystemWindows="true"被列入作为一个孩子到DrawerLayout也有android:fitsSystemWindows="true" I removed android:fitsSystemWindows="true" from nested (included) CoordinatorLayout and hiding toolbar started to work correctly. 我从嵌套(包含) CoordinatorLayout删除了android:fitsSystemWindows="true" ,并且隐藏工具栏开始正常工作。 I think you have to remove it from Toolbar. 我认为你必须从工具栏中删除它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 除非工具栏具有layout_scrollflags:scroll,否则CoordinatorLayout滚动将无法正常工作 - CoordinatorLayout scroll doesn't work unless Toolbar has layout_scrollflags:scroll 如何以编程方式为工具栏设置 app:layout_scrollFlags - How to set app:layout_scrollFlags for Toolbar programmatically app:layout_scrollFlags =“scroll | enterAlways”不适用于LinearLayout - app:layout_scrollFlags=“scroll|enterAlways” doesn't works with LinearLayout Android Material Design AppBarLayout的属性layout_scrollFlags有问题 - Android Material Design AppBarLayout's attribute layout_scrollFlags problematic 即使在提供“app:layout_scrollFlags”标志后,工具栏也不会滚动 - Toolbar is not scrolling off even after providing “app:layout_scrollFlags” flag 我们可以在除工具栏和AppbarLayout之外的其他视图中使用layout_scrollFlags - Can we use layout_scrollFlags in other views except Toolbar and AppbarLayout Material design layout_scrollFlags 含义 - Material design layout_scrollFlags meanings BottomAppBar和FloatingActionButton app:layout_scrollFlags行为 - BottomAppBar And FloatingActionButton app:layout_scrollFlags behavior 在CollapsingToolbarLayout中以编程方式更改layout_scrollFlags - Change layout_scrollFlags programmatically in CollapsingToolbarLayout 没有找到 app:layout_scrollflags 的资源 ID,来自 CollapsingToolbarLayout - no resource id found for app:layout_scrollflags from CollapsingToolbarLayout
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM