如何使 ListView 在 SplitPane 中展开?
How to make ListView expand in a SplitPane?
我正在使用 JavaFX 和 SceneBuilder 创建场景。在其中一个选项卡中有一个 SplitPane,当我将 window 置于最大尺寸并将其向上拖动以展开后一个视图时,它的行为与我希望的不同。 我希望 ListView 相应地扩展,但是一旦达到最大高度就会停止。如何解决这个问题?
这是一个屏幕截图:如您所见列表视图和拆分窗格分隔符之间有一个很大的space。
这是 xml 的代码:
<TabPane prefHeight = "400.0"
prefWidth = "600.0"
tabClosingPolicy = "UNAVAILABLE"
AnchorPane.bottomAnchor = "0.0"
AnchorPane.leftAnchor = "0.0"
AnchorPane.rightAnchor = "0.0"
AnchorPane.topAnchor = "28.0">
<tabs>
<Tab text = "Clump">
<content>
<SplitPane dividerPositions = "0.22713864306784662"
orientation = "VERTICAL">
<items>
<VBox alignment = "CENTER_LEFT"
spacing = "10.0">
<padding>
<Insets bottom = "10.0"
left = "10.0"
right = "10.0"
top = "10.0" />
</padding>
<children>
<HBox alignment = "CENTER_LEFT"
prefHeight = "100.0"
prefWidth = "200.0"
spacing = "10.0">
<children>
<RadioButton fx:id = "radioClump"
mnemonicParsing = "false"
selected = "true"
text = "Ricerca per clump ID">
<toggleGroup>
<ToggleGroup fx:id = "clumpSearch" />
</toggleGroup>
</RadioButton>
<TextField fx:id = "textClumpId"
promptText = "Clump id" />
<Button fx:id = "searchClumpButton"
mnemonicParsing = "false"
text = "Cerca" />
</children>
</HBox>
<RadioButton fx:id = "radioStar"
mnemonicParsing = "false"
text = "Clump che possono ospitare una stella massiccia"
toggleGroup = "$clumpSearch" />
</children>
</VBox>
<VBox alignment = "BOTTOM_CENTER"
prefHeight = "100.0"
prefWidth = "200.0">
<children>
<ListView>
<padding>
<Insets bottom = "15.0"
left = "15.0"
right = "15.0"
top = "15.0" />
</padding>
</ListView>
<HBox alignment = "BOTTOM_RIGHT"
prefWidth = "600.0"
spacing = "5.0">
<children>
<Button mnemonicParsing = "false"
text = "<" />
<Button mnemonicParsing = "false"
text = ">" />
</children>
<padding>
<Insets top = "5.0" />
</padding>
</HBox>
</children>
</VBox>
</items>
</SplitPane>
</content>
</Tab>
[... OTHER TABS ...]
</tabs>
</TabPane>
A VBox
将根据它们的 preferredHeight
调整其子节点的大小,除非另有说明。您可以通过在节点上设置静态 VBox
属性 vgrow
来覆盖此行为。在 FXML 中,语法为:
<ListView VBox.vgrow="ALWAYS">
<padding>
<Insets bottom = "15.0"
left = "15.0"
right = "15.0"
top = "15.0" />
</padding>
</ListView>
我正在使用 JavaFX 和 SceneBuilder 创建场景。在其中一个选项卡中有一个 SplitPane,当我将 window 置于最大尺寸并将其向上拖动以展开后一个视图时,它的行为与我希望的不同。 我希望 ListView 相应地扩展,但是一旦达到最大高度就会停止。如何解决这个问题?
这是一个屏幕截图:如您所见列表视图和拆分窗格分隔符之间有一个很大的space。
这是 xml 的代码:
<TabPane prefHeight = "400.0"
prefWidth = "600.0"
tabClosingPolicy = "UNAVAILABLE"
AnchorPane.bottomAnchor = "0.0"
AnchorPane.leftAnchor = "0.0"
AnchorPane.rightAnchor = "0.0"
AnchorPane.topAnchor = "28.0">
<tabs>
<Tab text = "Clump">
<content>
<SplitPane dividerPositions = "0.22713864306784662"
orientation = "VERTICAL">
<items>
<VBox alignment = "CENTER_LEFT"
spacing = "10.0">
<padding>
<Insets bottom = "10.0"
left = "10.0"
right = "10.0"
top = "10.0" />
</padding>
<children>
<HBox alignment = "CENTER_LEFT"
prefHeight = "100.0"
prefWidth = "200.0"
spacing = "10.0">
<children>
<RadioButton fx:id = "radioClump"
mnemonicParsing = "false"
selected = "true"
text = "Ricerca per clump ID">
<toggleGroup>
<ToggleGroup fx:id = "clumpSearch" />
</toggleGroup>
</RadioButton>
<TextField fx:id = "textClumpId"
promptText = "Clump id" />
<Button fx:id = "searchClumpButton"
mnemonicParsing = "false"
text = "Cerca" />
</children>
</HBox>
<RadioButton fx:id = "radioStar"
mnemonicParsing = "false"
text = "Clump che possono ospitare una stella massiccia"
toggleGroup = "$clumpSearch" />
</children>
</VBox>
<VBox alignment = "BOTTOM_CENTER"
prefHeight = "100.0"
prefWidth = "200.0">
<children>
<ListView>
<padding>
<Insets bottom = "15.0"
left = "15.0"
right = "15.0"
top = "15.0" />
</padding>
</ListView>
<HBox alignment = "BOTTOM_RIGHT"
prefWidth = "600.0"
spacing = "5.0">
<children>
<Button mnemonicParsing = "false"
text = "<" />
<Button mnemonicParsing = "false"
text = ">" />
</children>
<padding>
<Insets top = "5.0" />
</padding>
</HBox>
</children>
</VBox>
</items>
</SplitPane>
</content>
</Tab>
[... OTHER TABS ...]
</tabs>
</TabPane>
A VBox
将根据它们的 preferredHeight
调整其子节点的大小,除非另有说明。您可以通过在节点上设置静态 VBox
属性 vgrow
来覆盖此行为。在 FXML 中,语法为:
<ListView VBox.vgrow="ALWAYS">
<padding>
<Insets bottom = "15.0"
left = "15.0"
right = "15.0"
top = "15.0" />
</padding>
</ListView>