首页 文章

用gui builder和css代号 .

提问于
浏览
1

我正在构建一个cn1应用程序,到目前为止,它使用GUI Builder中的"Theme"来更改容器和按钮的外观 . 我现在想要为容器添加一个特定的边框,我发现通过css更容易完成边框,我在这里找到了如何操作和代码的说明:https://www.codenameone.com/blog/rounded-corners-shadows-and-gradients-with-css.html . 我添加了.jar,创建了一个css文件夹并添加了我的theme.css文件和代码 . 在我的形式's beforeshow method I change the uiid of a container to the uiid defined in my theme.css. However when I run the app the container takes on the default Container uiid, not the one defined in my .css. I feel like this is because I already have a theme defined in my gui builder with my uiids and now I am trying to change a container' s uiid到另一个主题中定义的uiid . 我有什么问题吗?

1 回答

  • 2

    如果我理解正确,您有两个主题,并且您希望在应用程序中使用两者中的元素 . 有两种有效的方案,一种是两个主题都在同一个res文件中,另一个是两个主题都在一个单独的文件中 .

    如果它们在同一个res文件中,请执行以下操作:

    theme = UIManager.initNamedTheme("/theme", "firstTheme");
    UIManager.getInstance().addThemeProps(theme.getTheme("secondTheme"));
    

    如果它们在单独的文件中,请执行以下操作:

    theme = UIManager.initNamedTheme("/theme", "firstTheme");
    Resources otherTheme = Resources.openLayered(("/otherTheme");
    UIManager.getInstance().addThemeProps(otherTheme.getTheme("secondTheme"));
    

    这在主题分层下的Codename One Developer Guide中讨论 .

相关问题