如何更改菜單中背景的顏色?它默認是白色的。我更改了style.xml和菜單,但它仍然顯示白色菜單。 是什麼問題,此代碼: 我可以刪除如何更改菜單中背景的顏色?
android:theme="@style/your_custom_optionsMenuStyle"
形式的manifest.xml和菜單的顏色變成黑色。但我想知道這是好方法嗎?並且在具有不同API的其他設備中是黑色的?
<item
android:id="@+id/menu_settings"
android:title="@string/menu_settings"
android:orderInCategory="100"/>
<item name="actionOverflowMenuStyle">@style/your_custom_optionsMenuStyle</item>
</menu>
style.xml文件: <
<!--
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>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="your_custom_optionsMenuStyle" parent="AppBaseTheme">
<item name="android:popupBackground">#000000</item>
</style>
</resources>
清單:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/your_custom_optionsMenuStyle"
>
的可能的複製[如何更改背景顏色彈出式菜單中的Android ](http://stackoverflow.com/questions/21231404/how-to-change-background-color-popup-menu-android) –
你有幾個零? https://en.wikipedia.org/wiki/Web_colors#Hex_triplet –
[如何更改ActionBar菜單背景顏色(android 4&5)](http://stackoverflow.com/questions/28974855/how-to -change-actionbar-menu-background-color-android-4-5) – camelCaseCoder