10

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.

Abdul Saleem
  • 10,098
  • 5
  • 45
  • 45
BernhardS
  • 978
  • 2
  • 10
  • 26
  • Welcome to Stack Overflow! We encourage you to [research your questions](http://stackoverflow.com/questions/how-to-ask). If you've [tried something already](http://whathaveyoutried.com/), please add it to the question - if not, research and attempt your question first, and then come back. –  Oct 01 '12 at 09:58

3 Answers3

36

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;
}
Dmitry Kotenko
  • 511
  • 4
  • 8
  • In addition to this, I find leaving the ColumnResizePolicy unconstrained and making the minimum column widths as wide as they need to be to fit everything in them, there is no horizontal scroll action when the table has the focus. – Mark Meyers Jun 10 '16 at 18:35
  • 1
    @MarkMeyers What is the ColumnResizePolicy? Where is it controlled? – Chrisuu Aug 28 '20 at 01:32
1

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.

ItachiUchiha
  • 36,135
  • 10
  • 122
  • 176
user1638436
  • 101
  • 1
  • 4
0

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.