2017-11-18 7 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のデフォルト値は「マージン」になります。つまり、レイアウトのセルごとに発生しているパディングを取得します。私は間隔がデフォルトでオンにもあると思うし、あなたが `vlayout.setSpacing(偽)であることを削除することができます

vlayout.setMargin(false) 
+0

;':だから、あなたはそれになりたい場所にlabel2を入れて、あなたはに呼んでいます – Jouni

関連する問題