How can I hide the horizontal scrollbar of a ListView? I tried it in different ways and probably it's totally easy, but I just can't get it to run.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Try this in the 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;
}
回答2:
Bit of a hack, but this should do it. In the CSS:
.list-view .scroll-bar:horizontal {
-fx-opacity: 0;
-fx-padding:-7;
}
Note that the scroll bar is still there, and mouse gestures around where it "should" be will result in scroll behavior.
回答3:
I think that would be nicer a ListCell with a Pane(for example StackPane) and a Label inside that will have the ellipsis functionality:
StackPane pane = new StackPane();
pane.setStyle("-fx-border-color:red;");
pane.setMinWidth(0);
pane.setPrefWidth(1);
pane.getChildren().add(label);
You can have a look at this link.
The same solution could be used for other ListCells complex.