如何始终在JavaFX中的ListView中显示滚动条

huangapple 未分类评论43阅读模式
英文:

How to always show scrollbar for ListView in JavaFX

问题

问题的要点是,我有一个 ListView,如果其中的 ListCell 超过了它可以容纳的大小,滚动条会出现并且“推动”内容向左移动。我该如何设置滚动条始终存在,而不管 ListCell 的数量如何?

以下是我的实现:

<VBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
    <ListView fx:id="ingredientListView" HBox.hgrow="ALWAYS"/>
</VBox>

在 JavaFX 中似乎没有像 Android 中的 ListView 那样的 fadeScrollbars="false" 属性。非常感谢任何帮助!

英文:

The gist of my problem is that I have a ListView, and if there are more ListCells in it than how many its size can accomodate, the scrollbar appears and "pushes" the content to the left. How do I set the scrollbar to always be present regardless of the number of ListCells?

Below is my implementation:

&lt;VBox xmlns=&quot;http://javafx.com/javafx/8&quot; xmlns:fx=&quot;http://javafx.com/fxml/1&quot;&gt;
    &lt;ListView fx:id=&quot;ingredientListView&quot; HBox.hgrow=&quot;ALWAYS&quot;/&gt;
&lt;/VBox&gt;

There doesn't seem to be the fadeScrollbars=&quot;false&quot; property that is available in ListView in Android. Appreciate any help!

huangapple
  • 本文由 发表于 2020年4月4日 17:49:04
  • 转载请务必保留本文链接:https://java.coder-hub.com/61026325.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定