我试图设置我的应用程序,所以我有一个半透明的状态和导航栏。
起初我遇到了状态栏与工具栏重叠的问题。当我有android:fitsSystemWindows =" false"在顶层。我发现有人说我应该把android:fitsSystemWindows =" true"不是在顶级,而是在第二级,所以它会填满窗口,但不会与状态栏重叠。
我把它放到工具栏中,现在我得到以下内容
我还尝试用另一个带有标志的LinearLayout包装整个布局,但它会关闭半透明效果吗?
它发生在kitkat和棒棒糖上。我迷失了发生的事情..
编辑:如果我将半透明导航栏变为false,则工具栏是正确的,但我丢失了半透明导航栏。
这是我的布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/orange"
android:clipToPadding="false"
android:fitsSystemWindows="true">
</android.support.v7.widget.Toolbar>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_material_light"
tools:context=".HomeActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<ListView
android:id="@+id/left_drawer"
android:layout_width="260dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/background_material_light" />
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
我的主题
<style name="AppTheme.Base" parent="Theme.AppCompat">
<item name="android:textColor">@color/black</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>