zawadz88/MaterialPopupMenu

Issue with setting Dark theme programatically

prscX opened this issue ยท 7 comments

prscX commented

Hi @zawadz88,

I am trying to set dark theme programatically using below API in Java:

MaterialPopupMenuBuilder popupMenuBuilder = new MaterialPopupMenuBuilder(); popupMenuBuilder.setStyle(R.style.Widget_MPM_Menu_Dark);

It is working as expected for text color but not for background color:

screen shot 2018-02-28 at 1 06 03 pm

I am not sure if I am missing something, can you please guide on how to set the Dark theme programatically.

Thanks
Pranav

Hi,
If I remember this correctly the background color comes from the Activity theme. So the Activity itself needs to have a dark theme.

prscX commented

Thanks @zawadz88 for the quick response.

Yes you are right the background color comes from the Activity theme. My use case is I am trying to invoke MaterialPopupMenu from RN react-native-popover-menu project, in order to make it work developers have to do changes at AndroidManifest file.

Is it possible to set the background color of entire Menu Popover through API? I am able to set the individual menu background through below snippet:

LinearLayout layout = (LinearLayout) o; layout.setBackgroundColor(getReactApplicationContext().getResources().getColor(R.color.mpm_popup_menu_background_color_dark));

screen shot

Thanks
Pranav

I think it might be possible by changing the default style used for showing the dialog.

I'll try to find some time this week and investigate.

Status update - I have the changes on https://github.com/zawadz88/MaterialPopupMenu/tree/feature/custom-background-colors
This needs some testing though and maybe some cleaning up.

I'll try to have something ready this week

prscX commented

Thanks @zawadz88 for taking this on priority and staying top on this.

I will also spend some time for testing and will share the results with you.

Thanks
Pranav

Hi @prscX,
This should be fixed in the newly released 1.4.0.

Thanks for reporting this!

prscX commented

Many Thanks @zawadz88 for release. I have tested and is working as expected.

Thanks
Pranav