Answer the question
In order to leave comments, you need to log in
Why are styles not included for popupMenu?
Help solve the problem. I want to create a popup-menu with a dark background and a white font color. But the user style is not connected for some reason to the menu.
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@null</item>
<item name="popupMenuStyle">@style/AppTheme.darkPopupStyle</item>
</style>
<style name="AppTheme.darkPopupStyle" parent="Widget.AppCompat.PopupMenu">
<item name="android:itemBackground">@drawable/popup_drawable</item>
<item name="android:textColor">@android:color/white</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<color
android:color="@android:color/darker_gray"/>
</item>
<item>
<color
android:color="@android:color/black"/>
</item>
</selector>
ContextWrapper wrapper = new ContextThemeWrapper(context, R.style.AppTheme_darkPopupStyle);
PopupMenu menu = new PopupMenu(wrapper, v);
android.support.v7.widget.PopupMenu
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question