以下是具有尺寸设置的UI树:
HorizontalLayout(大小已满)
FormLayout(未定义大小,扩展比率:0)
面板(尺寸已满,扩展比例:1)
我想要的是什么:
为FormLayout提供所需的最小空间,其余部分应由Panel占用。
发生了什么:
FormLayout的宽度为0(几乎不可见),Panel占据整个空间。
如果展开比率均为1,则表单布局和面板似乎具有完全相同的宽度。
我做错了吗?如何使FormLayout保持其大小,只有Panel会水平增长?
编辑:
主视图类:
private HorizontalLayout layout;
private FormLayout formLayout;
private TextField title;
private Upload upload;
private ComboBox<String> charset;
private Button btnSubmit;
private TextViewer textViewer;
public TextUploadView() {
createTitle();
createUpload();
createBtnSubmit();
createCharset();
formLayout = new FormLayout(title, upload, charset, btnSubmit);
textViewer = new TextViewer();
layout = new HorizontalLayout(formLayout, textViewer);
layout.setSizeFull();
layout.setExpandRatio(formLayout, 0);
layout.setExpandRatio(textViewer, 1);
}
TextViewer是带有标签的面板:
public class TextViewer extends Panel {
private static final long serialVersionUID = 1L;
private Label labelText;
public TextViewer() {
super();
labelText = new Label();
labelText.setWidth("100%");
labelText.setStyleName("largeTextDisplay");
super.setContent(labelText);
super.setSizeFull();
}
public void setText(String text) {
labelText.setValue(text);
}
}
我不认为标签上的css会造成任何问题,但是这就是:
.mytheme .largeTextDisplay {
white-space: pre-wrap;
word-wrap: normal;
}