1
votes

I got this button to switch themes:

public void onButtonThemeActionEvent(com.codename1.ui.events.ActionEvent ev) {


        if(index == 0) {
            index++;
            UIManager.initNamedTheme("/theme", "Leather");
            Display.getInstance().getCurrent().refreshTheme();
            }
            else if(index == 1) {
                index++;
                UIManager.initNamedTheme("/theme", "Chrome");
                Display.getInstance().getCurrent().refreshTheme();
            }
            else if(index == 2) {
                index++;
                UIManager.initNamedTheme("/theme", "FlatOrange");
                Display.getInstance().getCurrent().refreshTheme();
            }
            else if(index == 3) {
                index++;
                UIManager.initNamedTheme("/theme", "FlatBlue");
                Display.getInstance().getCurrent().refreshTheme();
            }
            else if(index == 4) {
                index++;
                UIManager.initNamedTheme("/theme", "FlatRed");
                Display.getInstance().getCurrent().refreshTheme();
            }
            else if(index == 5) {
                index = 0;
                UIManager.initNamedTheme("/theme", "Business");
                Display.getInstance().getCurrent().refreshTheme();
            }
    }

This code will change the themes in a sequence as you can see, the problem happens when changing from Leather to Chrome then as you can see in the image below in the Form title is missing a letter "Tela Principa" it should be "Tela Principal" instead.

OBS: This is an Android Device.

Chrome theme missing a letter in the Form title: Missing a letter in the Form title

After navigating through any menu and backing to Tela Principal, it is fixed as in the following image:

fixed after navigating through menus

How to fix this Chrome theme bug?

1

1 Answers

2
votes

You need to add a revalidate() after switching themes so the UI will update to new font sizes/padding/margin etc.

If that doesn't work try a forceRevalidate() which you shouldn't normally do but is sometimes necessary.