2015-08-26 52 views
0

我是一名Android新手,写过我的第一款使用操作栏和设计支持库的应用程序。但是,当我展开菜单时,它具有黑色背景色。在应用材料设计之前,菜单具有默认的灰色。我的colors.xml文件中没有任何深色。我怎样才能恢复正常的颜色? 下面是我在styles.xml创建的主题:在api上更改材质设计的菜单背景颜色8

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
     <item name="colorPrimary">@color/colorPrimary</item>    
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item>    
     <item name="colorAccent">@color/colorAccent</item>    
     <item name="android:textColorPrimary">@color/textColorPrimary</item>    
     <item name="android:textColorSecondary">@color/textColorSecondary</item>   
    </style> 

当我删除应用主题我的工具栏,我得到的正常颜色恢复正常,但操作栏的文字和的3点垂直圆点的颜色发生变化变黑。以下是我的activity_main的相关部分:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="@color/colorPrimary" 
     app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> 

</LinearLayout> 
+1

只是为了确定,你是否将你的主题添加到Android清单? –

+0

@AbdullahAsendar:是的。 Apptheme是默认的清单主题。我用我自己的设置覆盖了现有的主题。 – user1801060

+0

这可能不会帮助,但尝试将父级更改为父=“Theme.AppCompat.Light.DarkActionBar” –

回答

0

很简单。要更改操作栏弹出菜单的背景,你下面的属性添加到<android.support.v7.widget.Toolbar标签

app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 

您可以使用默认的样式或者更具体的色彩营造出你自己的。