【发布时间】:2018-06-24 20:32:53
【问题描述】:
VBox 中有一些按钮。我想将最后一个按钮对齐到 VBox 的底部。有没有办法做到这一点?
我试过this answer,但没用。
这是我的代码:
<VBox fx:id="presetVBox" prefHeight="580.0" prefWidth="180.0" style="-fx-background-color: white;">
<padding>
<Insets left="10.0" right="10.0"/>
</padding>
<Button fx:id="preset1Button" maxWidth="Infinity" mnemonicParsing="false"
prefWidth="Infinity" text="Load Preset 1">
<VBox.margin>
<Insets top="10.0"/>
</VBox.margin>
</Button>
<Button fx:id="preset2Button" maxWidth="Infinity" mnemonicParsing="false"
prefWidth="Infinity" text="Load Preset 2">
<VBox.margin>
<Insets top="10.0"/>
</VBox.margin>
</Button>
<Button fx:id="savePresetButton" maxWidth="Infinity" mnemonicParsing="false"
prefWidth="500.0" text="Save">
<!-- This button needs to aligned to the bottom of the VBox -->
<VBox.margin>
<Insets top="161.0"/>
</VBox.margin>
</Button>
</VBox>
【问题讨论】:
-
@Zephyr 我添加了一个 sn-p 代码。感谢收看。
-
将按钮包裹在另一个容器中,比如另一个
VBox,设置为VBox.vgrow="always" alignment="BOTTOM_CENTER",你应该设置好了。