CodenameOne - wrong theming for side-menu on Android device

42 Views Asked by At

I tried to run my Codename app on my Android phone

after sending the Android build

and I realized that the theme is perhaps wrong. I chose the native theming in the app.

Indeed I get a dark-grey side menu with black text that is very small, while the TextFields are in the right font and white background.

On the simulator (various Android devices skin) the theme seemed right, with good text size and background color.

Here's the relevant code:

mainForm.setToolbar(toolbar);
        toolbar.setEnabled(true);
        toolbar.showToolbar();

        BackCommand backCommand=new BackCommand("Back");
        mainForm.setBackCommand(backCommand);

        Container topBar = BorderLayout.west(new Label());
        
        String tagLine=.menu_tagline;

        topBar.add(BorderLayout.WEST, new Label(tagLine, "SidemenuTagline"));
        topBar.setUIID("SideCommand");
        toolbar.addComponentToRightSideMenu(topBar);


        toolbar.addMaterialCommandToRightSideMenu(help_menu_item, ' ', e -> {
            toolbar.closeRightSideMenu();
            new HelpViewer(appData, mainForm).show();
        });
        toolbar.addMaterialCommandToRightSideMenu(liability_disclaimer_menu_item, ' ', e -> {
            toolbar.closeRightSideMenu();
            
openDialog(mainForm,liability_disclaimer_dialog_title,liability_disclaimer));
        });
       
      ....
      ....
      ....

        toolbar.addMaterialCommandToRightSideMenu(about_menu_item, ' ', e -> {
            toolbar.closeRightSideMenu();
           
           openDialog(mainForm,about_dialog_title,about_dialog_text);

        });

What can be done to have the same theme for the menu? Or the readability for it?

1

There are 1 best solutions below

0
On

This video is a bit old but the basic concepts are still applicable: https://www.codenameone.com/how_di_i/how-do-i-create-gorgeous-sidemenu.html

The same concepts can be applied in CSS if you use CSS styling for the app. It's theoretically possible to customize a side menu from code but it would be REALLY hard as the menu is created dynamically internally within the framework.