导航抽屉视图背景颜色显示黑色背景

时间:2018-08-01 12:11:12

标签: android navigation-drawer

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

这是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>

我的原色,深色和重色

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

我尝试更改主色,暗色不起作用,也尝试更改导航视图的背景,但是设置颜色位于黑色之上,因此不是解决方案。欢迎您提供帮助

2 个答案:

答案 0 :(得分:0)

尝试更改背景色:

    $(document).ready(function(){
    var date_input=$('input[name="date"]');
    var container=$('.bootstrap-iso form').length>0 ? $('.bootstrap-iso form').parent() : "body";
    date_input.datepicker({
            format: "mm-yyyy",
            startView: "months", 
            minViewMode: "months",
            container: container,
            todayHighlight: true,
            autoclose: true,

    })
})

答案 1 :(得分:0)

使用android:background和所需的颜色并使用透明的app:itemBackground

<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"
    app:itemBackground="@android:color/transparent"
    android:background="@color/your_color" />