How to hide the horizontal Scrollbar of a ListView

2019-01-26 08:22发布

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.

3条回答
孤傲高冷的网名
2楼-- · 2019-01-26 08:59

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;
}
查看更多
Emotional °昔
3楼-- · 2019-01-26 09:03

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.

查看更多
Lonely孤独者°
4楼-- · 2019-01-26 09:13

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.

查看更多
登录 后发表回答