我正在尝试使用fitsSystemWindows =“true”获得半透明导航栏。它在kitkat中运行良好,半透明导航栏使用android:clipToPadding =“false”显示内容。但Lollipop导航栏不显示内容。
这是xml:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:clipToPadding="false"
tools:context=".MainActivity">
<!-- The main content view -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- Your main content -->
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="8dp"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<Button
android:layout_marginTop="24dp"
android:background="@color/md_red_500"
android:layout_gravity="center"
android:layout_width="200dp"
android:layout_height="800dp" />
</LinearLayout>
<!-- The navigation drawer -->
<com.videum.javier.myapplicationeliminmar.ScrimInsetsFrameLayout
android:clipToPadding="false"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/scrimInsetsFrameLayout"
android:layout_width="320dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white"
android:elevation="10dp"
android:fitsSystemWindows="true"
app:insetForeground="#4000">
<!-- Your drawer content -->
<Button
android:layout_marginTop="24dp"
android:background="@color/md_red_500"
android:layout_gravity="center"
android:layout_width="200dp"
android:layout_height="800dp" />
</com.videum.javier.myapplicationeliminmar.ScrimInsetsFrameLayout>
这是风格(相同的v19和v21):
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/md_red_500</item>
<item name="colorPrimaryDark">@color/md_red_700</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
java文件只有工具栏支持。
我需要fitSystemWindows永远保持真实。
导航抽屉在两个版本中都能正常工作。例如,如果我在其中添加一个按钮:navigation drawer opened
答案 0 :(得分:0)
您尚未在主题中指定,您负责绘制系统栏后面的内容:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
...
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
答案 1 :(得分:-1)
不要设置fitsSystemWindow =&#34; true&#34;在你的DrawerLayout中。默认情况下,系统窗口是状态栏和导航栏上方的窗口,即使您设置了windosTransclucentStatus / Navigation =&#34; true&#34;,这可能会让您思考&#34;现在窗口是全屏&#34;。如果你适合这个窗口,当然内容不会扩展到适合整个屏幕。