2017-11-18 4 views
2
  1. VerticalLayout 내부의 구성 요소가 가장자리의 일부 패딩과 함께 배치되는 이유는 무엇입니까?
  2. 이 문제를 해결하는 방법은 무엇입니까?

아래 코드는이 문제를 보여줍니다세로 레이아웃 패딩

@Component 
@UIScope 
public class TestForm extends CustomComponent { 

    public TestForm() { 

     HorizontalLayout hlayout = new HorizontalLayout(); 
     VerticalLayout vlayout = new VerticalLayout(); 
     hlayout.setSizeFull(); 
     vlayout.setStyleName("page"); 

     Label label1 = new Label("Label1"); 
     Label label2 = new Label("Label2"); 
     hlayout.addComponent(label1); 
     vlayout.addComponent(label2); 
     hlayout.addComponent(vlayout); 

     setCompositionRoot(hlayout); 
    } 

} 

결과 : enter image description here

감사합니다!

답변

2

Vaadin 8부터 VerticalLayout의 기본값은 "여백"을 가져야합니다. 즉, 레이아웃의 셀당 발생하는 패딩을 가져옵니다. 그래서 당신이 원하는 장소에 label2를 넣어, 당신은에 전화가 : 나는 간격하는 것은 기본적으로도 생각

vlayout.setMargin(false) 
+0

, 당신은 (false)를 vlayout.setSpacing '와 그것을 제거 할 수 있습니다;' – Jouni