本文介绍了如何在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的容器中心显示两个或多个标签
发布评论