我有一些按钮在一个 VBox
内。我想将最后一个按钮对齐到 VBox 的底部。有没有什么方法可以做到这一点?
我尝试了这个答案,但它没有起作用。
这是我的代码:
<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>
VBox
中,设置它的VBox.vgrow="always"
和alignment="BOTTOM_CENTER"
,然后你就可以了。 - Zephyr