android - 牛轧糖状态栏上的抽屉导航?

标签 android xml navigation-drawer statusbar appbar

我尝试在我的应用程序中构建抽屉导航,抽屉导航在以前版本的 nougat 中工作正常但在 nougat 抽屉导航中没有出现在状态栏上。我尝试了很多解决方案,但在牛轧糖中不起作用,请帮忙!!

这是我的 activity_main.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/drawerLayoutId"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <RelativeLayout
        android:fitsSystemWindows="true"    
        android:id="@+id/activity_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
    
        tools:context="com.example.pushpam.helloworld.MainActivity">
    
        <include
            layout="@layout/custom_tool_bar"
            android:id="@+id/customtollbarimportid"/>
    
        <TextView
            android:textSize="80dp"
            android:textColor="#E9CC0014"
            android:text="I"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/customtollbarimportid"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_marginLeft="65dp"
            android:layout_marginStart="65dp"
            android:layout_marginTop="79dp"
            android:id="@+id/textView" />
    
        <TextView
    
            android:textSize="80dp"
            android:textColor="#E9CC0014"
            android:text="Love"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textView2"
            android:layout_centerVertical="true"
            android:layout_centerHorizontal="true" />
    
        </RelativeLayout>
    
    <fragment
        android:fitsSystemWindows="true"
        android:id="@+id/nav_drawer_fragment_id"
        android:layout_width="280dp"
        android:layout_height="match_parent"
        app:layout="@layout/fragment_navigationfragment"
        android:layout_gravity="start"
        android:name="com.example.pushpam.helloworld.navigationfragment"
        tools:layout="@layout/fragment_navigationfragment" />
        
    </android.support.v4.widget.DrawerLayout>

我的样式.xml:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

</style>

<style name="CustomToolBarTheme">

    <item name="android:textColorPrimary">@color/toolBarTextColor</item>
    <item name="android:textColorSecondary">@color/toolBarTextColor</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

和样式(v21).xml

<resources>

    <style name="CustomToolBarTheme">
        <item name="android:textColorPrimary">@color/toolBarTextColor</item>
        <item name="android:textColorSecondary">@color/toolBarTextColor</item>
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">@android:color/transparent</item>
        <item name="android:windowTranslucentStatus">true</item>
    </style>
</resources>

my current navigation drawer

这是我当前想要在状态栏上方的抽屉导航。

最佳答案

你有一个彩色的状态栏。所以抽屉导航在它后面是不可见的。使您的状态栏透明,然后它就会在那里。

http://blog.raffaeu.com/archive/2015/04/11/android-and-the-transparent-status-bar/

<!-- Make the status bar traslucent -->
<style name="AppTheme" parent="AppTheme.Base">
    <item name="android:windowTranslucentStatus">true</item> // add this item tag inside your Theme Styles.xml and Styles(v21).xml:
</style>

关于android - 牛轧糖状态栏上的抽屉导航?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41626548/

相关文章:

android - 如何在谷歌眼镜中平移 WebView

android - React Native 中的抽屉

android - 将 RoboSpice 与 Jackson2 和 Spring 结合使用

android - 二进制 XML 文件第 1 行 : invalid drawable tag vector

java - Android: fragment 、SQLite 和加载器

html - 浏览器会在 SVG XML 中呈现命名空间 HTML 吗?

xml - 访问带或不带节点属性的innerXML

java - netbeans 7.2.1 中没有用于映射上下文监听器的 web.xml 文件

android - 以完整图像为背景的自定义 NavigationDrawer

android - 选择后如何在抽屉导航中使文本加粗?