2017-11-01 9 views
0

グリッドレイアウトには4つのボタンがあります。Vaadinの整列ボタン

enter image description here

私は

btnDetails.setSizeUndefined(); 
buttonsGrid.setComponentAlignment(btnDetails, Alignment.MIDDLE_LEFT); 

を使用していた。しかし、あなたが見ることができるようにボタンがあるためsetSizeUndefined の同じ幅()ではありません。

私は幅とボタンの高さを指定すると、私はこの結果を得る

enter image description here

あなたは、このようにボタンが並んでいないことがわかります。 私は

buttonsGrid.setComponentAlignment(btnDetails, Alignment.MIDDLE_LEFT); 

が含まれていたが、これはsetSizeUndefined ()なしで動作していないようです。

最初の画像のようにボタンを整列させる必要がありますが、幅は同じです。

おかげで、 キリル

+0

私はあなたが望むものを得るために、ボタンのアイコンとボタンのキャプションをscssに合わせる必要があると思います。 –

答えて

1

どのようにあなたのテーマでtext-align: leftを使用してはどうですか?このような何かが(Vaadin 8のためVaadinIconsFontAwesomeを置き換える):

Javaの:

public class GridLayoutWithLeftAlignedButtons extends GridLayout { 
    public GridLayoutWithLeftAlignedButtons() { 
     super(1, 4); 
     addButton("Details", FontAwesome.SEARCH); 
     addButton("Copy (Inhalt)", FontAwesome.FILE_TEXT); 
     addButton("Copy (Zeile)", FontAwesome.COPY); 
     addButton("Copy (ID)", FontAwesome.SERVER); 
    } 

    private void addButton(String caption, FontAwesome icon) { 
     Button newButton = new Button(caption, icon); 
     newButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); 
     newButton.addStyleName("black-background-white-text"); 
     newButton.setWidth("300px"); 
     addComponent(newButton); 
    } 
} 

テーマ:

.v-button.black-background-white-text{ 
    background-color: black; 
    color: white; 
    text-align: left; 
} 

結果:

vaadin-button-caption-alignment

+0

MulţumescMorfic –

+1

@KireProgramista :-)あなたは間違いなく大歓迎です。マイナーノート、 'tho:この時点では 'setComponentAlignment(newButton、Alignment.MIDDLE_LEFT);'は役に立たないので、削除することができます。私はあなたのサンプルからコピーして貼り付けました。もう1行のコードを保存することができます... – Morfic

関連する問題