2015-08-26 56 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" 

您可以使用默認的樣式或者更具體的色彩營造出你自己的。