我的状态栏出现问题,它被推离了我的工具栏。
我想要的功能是,当用户向下滚动 ListView
时,工具栏会消失在状态栏后面,以便只有选项卡可见,就像在 WhatsApp 和 YouTube 应用程序中一样。
为了达到这个效果或得到这个功能,我使用了这一行:
app:layout_scrollFlags="scroll|enterAlways"
进入我的 android.support.v7.widget.Toolbar
,但正如我之前所说,状态栏会被推开。
<?xml version="1.0" encoding="utf-8"?>
<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:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
最佳答案
我遇到了同样的问题并设法解决了它。只需删除行:
android:fitsSystemWindows="true"
来自协调器布局。您可以在 ViewPager 的布局中进一步降低它,但在顶层它似乎会导致该问题。
关于android - 工具栏将状态栏推开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33978134/