导航抽屉视图背景颜色显示黑色背景 [英] Navigation drawer view background color showing black background

查看:104
本文介绍了导航抽屉视图背景颜色显示黑色背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面临一个奇怪的问题,我的应用程序中有一个导航抽屉活动,当在低于API 21的条件下运行的应用程序我发现工具栏出现错误时,我通过更改工具栏颜色对其进行了修复.变成黑色.我找不到它如何变成黑色.

I am facing a weired issue, I have a navigation drawer activity in my app, and i found some errors with toolbar when app running on below API 21 i have fixed it by changing toolbar color.And accidently the navigation drawer color changed to black .I could not find how it changed to black in color.

这是navigationView

Here is the navigationView

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">

<include
    layout="@layout/app_bar_home_page_new"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    app:headerLayout="@layout/nav_header_home_page_new"
    app:menu="@menu/activity_home_page_new_drawer" />

 and the toolbar layout

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
tools:context=".NEWUI.HomePageNew">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
      android:id="@+id/toolbar"
      android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
      android:background="?attr/colorPrimary"
      app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_home_page_new" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="@dimen/fab_margin"
    app:backgroundTint="@color/colorFab"
    app:srcCompat="@drawable/ic_fab_svg" />
 </android.support.design.widget.CoordinatorLayout>

我的原色,深色和强调色

And my color primary ,primary dark and accent color

 <color name="colorPrimary">#2B2B2B</color>
<color name="colorPrimaryDark">#2B2B2B</color>
<color name="colorAccent">#FFF</color>

和我的风格

<resources xmlns:android="http://schemas.android.com/apk/res/android">

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>


<style name="AppTheme" parent="AppTheme.Base">
    <!-- 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="treeViewListStyle" parent="android:style/Widget.ListView">
    <item name="android:background">@android:color/white</item>
    <item name="android:divider">@drawable/divider</item>
</style>

<!--  Transparent dialog -->
<style name="TransparentProgressDialog" parent="@android:style/Theme.Dialog">
    <item name="android:windowFrame">@null</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowTitleStyle">@null</item>
    <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
    <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
    <item name="android:backgroundDimEnabled">true</item>
    <item name="android:background">@android:color/transparent</item>
</style>

<style name="TabLargeTextTheme" parent="@android:style/Theme">
    <item name="android:tabWidgetStyle">@style/TabLargeWidget</item>
</style>

<style name="TabLargeWidget" parent="@android:style/Widget.TabWidget">
    <item name="android:textAppearance">@style/TabLargeWidgetText</item>
</style>

<style name="TabLargeWidgetText" parent="@android:style/TextAppearance.Widget.TabWidget">
    <item name="android:textSize">16sp</item>
    <item name="android:textStyle">bold</item>
    <item name="android:textAllCaps">true</item>
</style>

<style name="alert_dialog" parent="android:Theme.Dialog">
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowIsTranslucent">false</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowFullscreen">false</item>
    <item name="android:windowBackground">@color/float_transparent</item>
    <item name="android:windowAnimationStyle">@null</item>
    <item name="android:backgroundDimEnabled">true</item>
    <item name="android:backgroundDimAmount">0.4</item>
</style>

<style name="dialog_blue_button" parent="android:Widget.Button">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">31dp</item>
    <item name="android:background">@drawable/blue_button_background</item>
    <item name="android:textSize">14sp</item>
    <item name="android:paddingLeft">21dp</item>
    <item name="android:paddingRight">21dp</item>
    <item name="android:textColor">@color/black</item>
</style>

<!--Style for the normal font to be used across the application -->
<style name="style_medium_font">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>
<!--Style for the font to be used in buttons -->
<style name="style_button_font">
    <item name="android:textAppearance">?android:attr/textAppearanceLarge</item>
       <item name="android:textColor">@android:color/primary_text_dark</item>
      <item name="android:background">#CC000000</item>
     </style>

      <style name="style_pwd_dialog_button_font" 
        parent="style_button_font">
        <item name="android:textAppearance">? 
       android:attr/textAppearanceMedium</item>
        </style>

     <style name="AppTheme.AppBarOverlay" 
     parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

    <style name="AppCompatAlertDialogStyle" 
    parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="colorAccent">#FFCC00</item>
    <item name="android:textColorPrimary">#FFFFFF</item>
    <item name="android:background">#5fa3d0</item>
</style>

<style name="AppTheme.Base" parent="Theme.AppCompat.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<!--<style name="ToolBarStyle" parent="">-->
<!--<item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>-->
<!--<item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>-->
<!--</style>-->

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

 <style name="TextLabel" parent="TextAppearance.Design.Hint">
    <item name="android:textSize">10sp</item>
       </style>
        </resources>

我尝试更改原色,暗色不起作用,也尝试更改导航视图的背景,但是设置颜色位于黑色之上,所以这不是解决方案.感谢您的帮助

I have tried changing my color primary ,dark n accent it doesnt work also tried to change the background of navigation view but the setting color is on top that black color so it is not a solution.Any help is appreciated

推荐答案

尝试更改背景色:

<android.support.design.widget.NavigationView
 android:id="@+id/nav_view"
 android:layout_width="wrap_content"
 android:layout_height="match_parent"
 android:layout_gravity="start"
 android:fitsSystemWindows="true"
 app:headerLayout="@layout/nav_header_home_page_new"
 app:menu="@menu/activity_home_page_new_drawer"
 android:backgroundTint="#ffffff"/>

这篇关于导航抽屉视图背景颜色显示黑色背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆