table 布局代号 one 中的多行 textArea 对齐

Multiple line textArea alignment in table layout codenameone

在上图中,其中一列有 2 行的文本区域。所以该行占据了它的高度。现在我想将所有单行文本区域垂直居中,因为 well.Found setVerticalAlignment 等方法仅适用于单行文本区域。如何让 textArea 居中垂直对齐?

我的代码:

TableLayout tl = new TableLayout(1, 5);
Container containerTableHeading = new Container(tl);
TextArea tableName = new TextArea("Table Name");
tableTextAreaStyle(tableName);
TextArea inaugurationDate = new TextArea("Inauguration Date");
tableTextAreaStyle(inaugurationDate);
TextArea areaCode = new TextArea("Area Code");
tableTextAreaStyle(areaCode);
TextArea clubAbbrName = new TextArea("Club Abbr Name");
tableTextAreaStyle(clubAbbrName);
TextArea clubCharterDate = new TextArea("Club Charter Date");
tableTextAreaStyle(clubCharterDate);
containerTableHeading.add(tl.createConstraint().widthPercentage(30), tableName);
containerTableHeading.add(tl.createConstraint().widthPercentage(20), inaugurationDate);
containerTableHeading.add(tl.createConstraint().widthPercentage(15), areaCode);
containerTableHeading.add(tl.createConstraint().widthPercentage(15), clubAbbrName);
containerTableHeading.add(tl.createConstraint().widthPercentage(20), clubCharterDate);

textArea 样式:

public void tableTextAreaStyle(TextArea textAreaName) {
        textAreaName.setUIID(textAreaName.getText());
        textAreaName.setEditable(false);
        textAreaName.setGrowByContent(true);
        textAreaName.setGrowLimit(2);
    }

你不能。

解决方法是将 TextArea 包裹在 Container 中使其居中,或者使用 TableLayout.

align/valign 约束