如何隐藏 ListView 的水平滚动条?我尝试了不同的方法,可能很容易,但我就是无法让它运行。
尝试在CSS中使用以下代码:
.list-view .scroll-bar:horizontal .increment-arrow,
.list-view .scroll-bar:horizontal .decrement-arrow,
.list-view .scroll-bar:horizontal .increment-button,
.list-view .scroll-bar:horizontal .decrement-button {
-fx-padding:0;
}
我认为使用一个Pane(例如StackPane)和一个Label的ListCell会更好,这样可以实现省略功能:
StackPane pane = new StackPane();
pane.setStyle("-fx-border-color:red;");
pane.setMinWidth(0);
pane.setPrefWidth(1);
pane.getChildren().add(label);
你可以查看这个链接。
相同的解决方案也可用于其他复杂的ListCells。
有些取巧,但这应该可以实现。在 CSS 中:
.list-view .scroll-bar:horizontal {
-fx-opacity: 0;
-fx-padding:-7;
}