Android: change background Color of the ContextMenuContainer
Closed this issue · 7 comments
Is it possible to change the background Color of ContextMenuContainer? (in android for now)
if you can give me a hint so I can implement it myself and I can then send a PR, I have tried a lot but no luck (since I have 0 experience in Android Native)
thanks in advance
hi @Shaboo , what do you mean by background number and what are you trying to achieve?
holy, I meant Background Color
basically I want the background Color of the Whole menu to be changed, now it is always kinda white
I think one way to achieve that is to change your app theme as described here https://stackoverflow.com/questions/21231404/how-to-change-background-color-popup-menu-android
Couldn't be cross platform option? like a background color property?
it would be really useful, specially when you dealing with Dark & Light mode stuff.
nope, since other platforms doesn't provide such functionality. Also provided solution should be sufficient to support light and dark modes on Android.
@anpin thanks for the suggestion, I did the following
in Styles.xml
<style name="pop" parent="Widget.AppCompat.PopupMenu">
<item name="android:textColor">@android:color/white</item>
<item name="android:itemBackground">#606060</item>
</style>
and inside MainTheme
I added
<style name="MainTheme" parent="MainTheme.Base">
......
<item name="android:popupMenuStyle">@style/pop</item>
</style>
then in ContextMenuContainerRenderer
.ConstructNativeMenu
Context wrapper = new ContextThemeWrapper(Context, Resource.Style.pop);
contextMenu = new PopupMenu(wrapper, child);
then it worked, thanks again