【问题标题】:to make navigation drawer on status bar?在状态栏上制作导航抽屉?
【发布时间】:2017-01-12 10:23:04
【问题描述】:

我正在开发 Android 项目,并且正在实现 Navigation Drawer。我正在阅读新的 Material Design Spec 和 Material Design Checklist。 但我无法解决我的问题。 请任何人帮助我?看截图。 下面是我的导航抽屉的屏幕截图没有覆盖在状态栏上

我想变成那个截图。导航抽屉在状态栏结束

【问题讨论】:

    标签: android


    【解决方案1】:

    按照以下步骤操作: 在您的样式中添加一个新主题:

    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"
    

    就是这样。

    【讨论】:

    • 无法解决@Pushpendra Choudhary。我的 statusBarColor 是#FFFFFF。我不想透明。谢谢
    【解决方案2】:
    <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>
    

    【讨论】:

    • 无法解决@Rahul Karande.Nav 抽屉在状态栏下是透明的。我想将 navdrawer 覆盖在状态栏上。谢谢
    【解决方案3】:

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

    1)文件 2)新的 3)活动 4)导航抽屉 并转到下一个并在此使用您的代码

    希望对你有帮助

    【讨论】:

    • 谢谢@Rahul Karande。这是正常的导航抽屉。请看我的问题。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2014-12-27
    • 1970-01-01
    • 2015-01-10
    • 2017-05-28
    • 1970-01-01
    • 2015-05-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多