1
votes

I have created an application to test the new CN1 CSS support.

The plugin is great and everything works fine and out-of-the-box, except that the material icon on a button does not change its color with the button's text color. It just stays always the same (black) color.

Before using the CSS support, I changed the theme editor's default foreground color setting to reach the material icon, but now the theme editor seems to be dis-attached from the styling and it does not have any effect anymore.

Is there a UIID for the icon or any other way to change the color of the material icon?

Here is my code:

    FontImage icon = FontImage.createMaterial(FontImage.MATERIAL_CHECK, "TitleCommand", 3);        
    Button buttonTest = new Button("Test css");
    buttonTest.setUIID("ButtonTest");        
    buttonTest.setIcon(icon);

And the CSS:

    ButtonTest {
        color: red;
    }
2
FontImage creates an image based on the current style during creation. Once created the icon won't change even if you change the style after the fact. This has advantages and disadvantages. We added a setMaterialIcon() method to label. I'm considering the option of making it behave like that so it updates with changes to the theme - Shai Almog
Shai, thanks for your reply. I use and like the material icons a lot and I find it rather a disadvantage not to able to influence the color, since from the layout point of view it can somehow distort the harmony of the screen's appearance and you are limited to the color you chose at project start. Of course you know what is best for your product. What are the advantages you mention? I also could not locate the setMaterialIcon() method for the label. - rainer
You'd need to update the libs to get that method. It's not a disadvantage because regular icons won't change their color either. You will only see this if you change a theme dynamically but for most apps that doesn't happen. - Shai Almog

2 Answers

2
votes

try it

FontImage img = FontImage.createMaterial(FontImage.MATERIAL_THUMB_UP, style);
0
votes

Just to post a complete answer that might be able to guide someone:

Style style = new Style();
style.setBgColor(ColorUtil.GREEN);
style.setFgColor(ColorUtil.WHITE);
style.setBgTransparency(255);

FontImage imageBack = FontImage.createMaterial(FontImage.MATERIAL_NEXT_WEEK, style);