我在中有一些按钮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>
Region
在按钮和最后一个子项之前的子项之间添加一个空格。如果VBox.vgrow
将此节点的属性设置为ALWAYS
,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="preset2Button" maxWidth="Infinity" mnemonicParsing="false"
prefWidth="Infinity" text="Load Preset 2">
<VBox.margin>
<Insets top="10.0"/>
</VBox.margin>
</Button>
<Region VBox.vgrow="ALWAYS" />
<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="10.0"/>
</VBox.margin>
</Button>
</VBox>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句