标签垂直对齐不起作用

时间:2016-04-10 06:05:22

标签: codenameone

我有一个带有Icon的标签,我试图在底部设置垂直对齐,但它不起作用。这是一个问题吗?

Form hi = new Form("Label");
hi.add(new Button("Upper Border"));
Label bottomLabel = new Label("Label Text Bottom");
bottomLabel.setIcon(theme.getImage("Orange Line.png"));
bottomLabel.setVerticalAlignment(Component.BOTTOM);
hi.add(bottomLabel);
hi.add(new Button("Bottom Border"));
hi.show();

enter image description here

EDITED

我不希望达到上图所示的确切布局。这只是我需要的一个例子。我希望能够添加带有Icon的标签并在底部设置文本。但我不想使用容器来做,因为我需要在底部添加几行包含Icon和文本的行。以下是我想要学习的例子:

enter image description here

1 个答案:

答案 0 :(得分:1)

您可以使用borderlayout在表单底部设置标签,如下面的代码所示。我更改了表单的布局并将标签设置为底部

    Form hi = new Form("Label");
    **hi.setLayout(new BorderLayout());**
    hi.add(BorderLayout.NORTH,new Button("Upper Border"));
    Label bottomLabel = new Label("Label Text Bottom");
    bottomLabel.setIcon(theme.getImage("Orange Line.png"));
    bottomLabel.setVerticalAlignment(Component.BOTTOM);
    **hi.add(BorderLayout.SOUTH,bottomLabel);**
   //hi.add(new Button("Bottom Border"));
    hi.show();