在状态栏上制作导航抽屉?

时间:2017-01-12 10:23:05

标签: android

我正在研究Android项目,我正在实施导航抽屉。我正在阅读新的材料设计规范和材料设计清单。 但我无法解决我的问题。 请有人帮帮我吗?看看截图。 下面是我的导航抽屉的屏幕截图,状态栏上没有封面

enter image description here

我希望像截图一样。导航抽屉已经在状态栏上结束了

enter image description here

3 个答案:

答案 0 :(得分:0)

请按照以下步骤操作: 在工作室

1)文件  2)新 3)Actvity 4)NavigationDrawer 并转到下一个和用户的代码

我希望它能帮到你

答案 1 :(得分:0)

请按以下步骤操作:   在你的风格中添加一个新主题:

<强>值/ styles.xml

<style name="AppTheme.NoActionBar">  
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<强>值/ 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  
    android:name="MyDrawerNavActivity"
    android:theme="@style/AppTheme.NoActionBar"

就是这样。

答案 2 :(得分:0)

<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" />

值/的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>

相关问题