【发布时间】:2017-01-12 10:23:04
【问题描述】:
我正在开发 Android 项目,并且正在实现 Navigation Drawer。我正在阅读新的 Material Design Spec 和 Material Design Checklist。 但我无法解决我的问题。 请任何人帮助我?看截图。 下面是我的导航抽屉的屏幕截图没有覆盖在状态栏上
我想变成那个截图。导航抽屉在状态栏结束
【问题讨论】:
标签: android
我正在开发 Android 项目,并且正在实现 Navigation Drawer。我正在阅读新的 Material Design Spec 和 Material Design Checklist。 但我无法解决我的问题。 请任何人帮助我?看截图。 下面是我的导航抽屉的屏幕截图没有覆盖在状态栏上
我想变成那个截图。导航抽屉在状态栏结束
【问题讨论】:
标签: android
按照以下步骤操作: 在您的样式中添加一个新主题:
values/styles.xml
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
values/styles.xml(v21)
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
指定您的 Activity 现在使用这个主题,就像这样
<activity
android:name="MyDrawerNavActivity"
android:theme="@style/AppTheme.NoActionBar"
就是这样。
【讨论】:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
<include layout="@layout/toolbar" />
<!-- Main layout -->
<FrameLayout
android:id="@+id/main_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<!-- Nav drawer -->
<fragment
android:id="@+id/fragment_drawer"
android:name="com.example.DrawerFragment"
android:layout_width="@dimen/drawer_width"
android:layout_height="match_parent"
android:layout_gravity="left|start"
android:fitsSystemWindows="true" />
values/themes.xml
<style name="AppTheme" parent="AppTheme.Base">
<!--This makes the status bar transparent in KK and Lollipop-->
<!--You do not need values-v21 and if you create them make sure you extend from this one-->
<item name="android:windowTranslucentStatus">true</item>
【讨论】:
按照以下步骤操作: 在工作室里
1)文件 2)新的 3)活动 4)导航抽屉 并转到下一个并在此使用您的代码
希望对你有帮助
【讨论】: