[英]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"
. 我的问题是,
CordinatorLayout
与android: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.