Overwrite styles

75 views
Skip to first unread message

Sven

unread,
Jul 3, 2013, 6:12:13 AM7/3/13
to codenameone...@googlegroups.com
Hi,
I try to define different styles for different platforms in the Designer.

I tried this by  
  • selecting a Plattform e.g iOS (iPhone/iPod & iPad) 
  • click the green icon on the theme 
  • change a style
  • save
I tried it in the simulator and it always displays the base Resource and not the style defined for the specific platform. 
In the preview of the Designer all the styles are displayed correctly when I switch between between the platforms.

Do I miss a step ? Or does overwriting only works for images (as shown in the theming video)? Or is it a better way to create a different Theme for each platform and load these from code?


Thanks a lot,
Sven



Shai Almog

unread,
Jul 3, 2013, 11:01:23 AM7/3/13
to codenameone...@googlegroups.com
You would effectively replace the entire theme and not just a particular style within the theme. You can define an additional blank theme (make sure its a blank theme and not a native theme) then in override mode override it and make changes to it. Save.
Now when you load the theme or init the theme just use addThemeProps(resourceFile.getTheme("Override"));
Your definitions will be overlaid on top of the existing theme.

Sven

unread,
Jul 19, 2013, 6:02:30 AM7/19/13
to codenameone...@googlegroups.com
It's been a while but I stil got a problem.
  • I created a new theme (blank and called "Android Overwrite")
  • I selected the theme, chose from Override In Platform: "Android (phones & tablets)"
  • clicked the green icon on the theme
  • made changes to elements
  • saved it
  • added following line in the initVars method in userclasses.StateMachine.java
    • UIManager.getInstance().addThemeProps(res.getTheme("Android Override"));
  • result: the changes are not displayed
When I do not overwrite the "Android Overwrite" theme and just change the base resource of the "Android Override" theme the styles are applied correctly.

So at the moment I solve the problem this way:

if(Display.getInstance().getPlatformName().equals("and")){
     
UIManager.getInstance().addThemeProps(res.getTheme("Android Override"));
}

But I guess it also should work by using the Overwrite Possibilities of the GUI Builder.

Do I miss a step?

Shai Almog

unread,
Jul 19, 2013, 2:29:50 PM7/19/13
to codenameone...@googlegroups.com
That's weird I answered this and somehow it disappeared...
Are you using Eclipse or NetBeans?
When you look in the override directory you should see an override file containing your android specific change, when sending an android build is this file packaged into the jar?

Sven

unread,
Jul 22, 2013, 3:51:08 AM7/22/13
to codenameone...@googlegroups.com
I'm using Eclipse.
The override folders contains an android file with the changes.

The jar inside the dist folder does not contain any files inside the override folder. Is this the right jar?

Shai Almog

unread,
Jul 22, 2013, 10:36:14 AM7/22/13
to codenameone...@googlegroups.com
Is your plugin up to date?
If you go into the settings and click OK does it offer to update the build.xml?
If so can you accept that?

Assuming you are using the latest plugin with the latest build.xml this could be a bug in Eclipse.

Shai Almog

unread,
Jul 22, 2013, 10:36:33 AM7/22/13
to codenameone...@googlegroups.com
In the Eclipse plugin that is ;-)

Sven

unread,
Jul 23, 2013, 3:43:34 AM7/23/13
to codenameone...@googlegroups.com
I updated my plugin and the build.xml is also up to date.


In the Eclipse plugin that is ;-)

ah okay in this case I will just stick with my workaround until this bug is fixed. Thanks for your help.

Shai Almog

unread,
Jul 23, 2013, 3:09:29 PM7/23/13
to codenameone...@googlegroups.com
Can you please file an issue on this?

Sven

unread,
Jul 24, 2013, 3:50:43 AM7/24/13
to codenameone...@googlegroups.com

Shai Almog

unread,
Jul 24, 2013, 1:20:57 PM7/24/13
to codenameone...@googlegroups.com
Thanks.
Reply all
Reply to author
Forward
0 new messages