我正在尝试在我的应用程序中应用主题。一切正常,除了我用display_menu.xml文件膨胀的菜单。我在这里做错了什么?
我的styles.xml
<style name="AppTheme.Dark">
<!-- Customize your theme here. -->
<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:colorBackground">@color/colorBackground</item>
<item name="android:textColorSecondary">@color/textColorPrimary</item>
<item name="android:windowBackground">@color/colorBackground</item>
<item name="android:textColorSecondaryInverse">@color/textColorPrimary</item>
<item name="android:textColor">@color/textColorPrimary</item>
<item name="cardStyle">@style/CardView.Dark</item>
<item name="android:popupMenuStyle">@style/MyApp.PopupMenu</item>
</style>
<style name="MyApp.PopupMenu" parent="android:Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">@drawable/menu_dropdown_panel</item>
<item name="android:textAppearanceListItem">@style/MyText</item>
</style>
<style name="MyText">
<item name="android:textColor">@color/colorAccent</item>
</style>
我的display_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/action_refresh"
android:title="@string/action_refresh"
app:showAsAction="never" />
</menu>
我正在夸大它
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.display_menu, menu);
return true;
}
我的菜单项显示如下:
这是我试图放在背景中的可绘制的:
我试图将菜单项的背景作为我的colorPrimary **和文本颜色为textColorPrimary
答案 0 :(得分:0)
这有助于我
将popupMenu样式添加到您的AppTheme:
<style name="AppTheme" parent="android:Theme.Light">
<item name="android:popupMenuStyle">@style/PopupMenu</item>
</style>
<style name="PopupMenu" parent="@android:style/Widget.PopupMenu">
<item name="android:popupBackground">@android:color/white</item>
</style>
<强>的manifest.xml:强>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
.............
</application>