I'm using built-in android popup menu but the result is this:
PopupMenu popupMenu = new PopupMenu(context, holder.menu);
popupMenu.getMenuInflater().inflate(R.menu.item_menu, popupMenu.getMenu());
and the item_menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/one"
android:title="item1"/>
<item
android:id="@+id/two"
android:title="item2"/>
<item
android:id="@+id/three"
android:title="item3"/>
</menu>
and the styles for the theme
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="popupMenuStyle">@style/PopupMenu</item>
</style>
<style name="PopupMenu" parent="Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">#FFFFFF</item>
</style>
Likely to be the Context
type:
Parent of my AppTheme is Theme.AppCompat.Light.DarkActionBar
and parent of my activity is AppTheme
// Background = black and textColor = black
PopupMenu popupMenu = new PopupMenu(getBaseContext() , view); // don't use getBaseContext()
// Background = black and textColor = white
PopupMenu popupMenu = new PopupMenu(getApplicationContext() , view); // don't use getApplicationContext()
so you must just use Activity Context:
// Background = light and textColor = dark
PopupMenu popupMenu = new PopupMenu(YourActivity.this , view); // this is ok
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With