如何在codenameone的容器中心显示两个或多个标签

编程入门 行业动态 更新时间:2024-10-27 08:33:32
本文介绍了如何在codenameone的容器中心显示两个或多个标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是Codenameone的新手,是否有任何选项可以使标签对齐取决于另一个标签,例如对齐底部,顶部,右侧和左侧选项?

I am new for Codenameone Is there any option to align a label depends on another label like align bottom, top, right and left option?

如何对齐许多标签标签位于父级布局的中心?

How to align many labels at the centre of the parent layout?

在这里,我附加了尝试使用的代码:

Container center = new Container(new BorderLayout()); Label des = new Label((String) data.get("title")); des.setUIID("MultiLine2"); center.addComponent(BorderLayout.NORTH,des); Label author = new Label((String) data.get("author")); author.setUIID("MultiLine2"); center.addComponent(BorderLayout.SOUTH,author); cnt.addComponent(BorderLayout.CENTER, center);

我正像下面的图片一样出人意料

在这里,我已经附加了我的项目所需的内容

有人可以帮助我如何获得我的要求?

推荐答案

这会将标签放置在容器的绝对中心:

This will place the Labels in the absolute center of the container:

Form hi = new Form("Hi World"); hi.setLayout(new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE)); Container center = new Container(new BoxLayout(BoxLayout.Y_AXIS)); Label line1 = new Label("What are you doing"); Label line2 = new Label("Hello"); center.add(line1); center.add(line2); hi.addComponent(BorderLayout.CENTER, center); hi.show();

要调整中心以将其稍微向左移动,可以在中间容器中添加右填充:

To adjust the center to move slightly to the left you can add right padding to the center Container:

center.getAllStyles().setPadding(Component.RIGHT, 100);

更多推荐

如何在codenameone的容器中心显示两个或多个标签

本文发布于:2023-10-08 09:58:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1472293.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   容器   两个   标签   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!