如何在调整滚动窗格大小时增大由滚动窗格包装的流窗格



我有一个ScrollPane,里面有一个FlowPane。当我通过拖动边缘来调整窗口大小时,流窗格不会增长!它保持其固定大小。当滚动窗格被鼠标展开时,如何调整流窗格的大小?

我尝试了很多方法,但没有运气!这是我最简单的 fxml 代码:

<ScrollPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/11.0.1">
   <content>
      <FlowPane prefHeight="411.0" prefWidth="613.0" style="-fx-background-color: green;" />
   </content>
</ScrollPane>

答案很简单。但不知道为什么没有人回答。经过数小时的测试,我找到了解决方案。如果其他人有同样的问题,我分享答案。

          <ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="ALWAYS" prefHeight="670.0" prefWidth="434.0" vbarPolicy="ALWAYS" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="6.0" AnchorPane.topAnchor="0.0">

最新更新