Adjust uiids from code?

17 views
Skip to first unread message

Gareth Murfin

unread,
Mar 13, 2018, 3:08:37 PM3/13/18
to CodenameOne Discussions
Ive done a whole app using the old gui builder, and specified the themes manually etc with various shades of orange. Now the client wants to download these shades from an api and apply them. Is there any way to do this? Ie, can I somehow adjust the uiid properties from code? to say change orange to blue ? If not what is the recommended way to do this sort of thing?. I thought originally id write a java app to simply edit the .ui files on disk, but I didnt consider they may want it fully dynamic from their api!.

Thanks again for all the support, 
Gaz

Shai Almog

unread,
Mar 14, 2018, 1:09:33 AM3/14/18
to CodenameOne Discussions
You can use addThemeProps() to add a theme layer on top e.g. this guy used it to increase font size:

https://stackoverflow.com/questions/48851909/codename-one-modify-a-font-size-in-a-theme-like-in-an-hashtable

Color is even simpler as its just a HEX RGB string e.g. "ffffff" so you can code it as

HashMap themeLayer = new HashMap();
themeLayer
.put("MyComponent.bgColor", "cccccc");
UIManager.getInstance().addThemeProps(themeLayer);
form
.refreshTheme();


Gareth Murfin

unread,
Mar 14, 2018, 7:12:03 AM3/14/18
to CodenameOne Discussions
Wow! That is awesome, gonna try it out.
Reply all
Reply to author
Forward
0 new messages