在代号一的常规文本中嵌入 material 个图标字符

Embedding material icons charcters in regular text in CodenameOne

有没有办法在常规文本段落中插入 material 图标字符?

所以我需要这样的东西:"Some text"+material 图标字符在这里+“一些更多的文字”。我希望它正常流动,没有多余的线条。

谢谢。

我想根据这个问题的泛化程度,有几种方法。例如,复杂的解决方案可以是 RichTextView class 的扩展以支持此功能 (http://www.codenameone.com/blog/tip-rich-view-revisited.html)。

但是,一个基本的方法可能是在 Container 中放置两个或三个 Label,并使用 FlowLayout 布局。例如下面的代码:

    Form hi = new Form("Hi World", BoxLayout.y());

    Container textWithMaterialIconInside = new Container(new FlowLayout(Component.LEFT));
    textWithMaterialIconInside.add(new Label("Some text", "Label"));
    textWithMaterialIconInside.add(new Label(FontImage.createMaterial(FontImage.MATERIAL_BACKUP, UIManager.getInstance().getComponentStyle("Label"))));
    textWithMaterialIconInside.add(new Label("and other text", "Label"));

    hi.add(textWithMaterialIconInside);
    hi.show();

生成此内容: