I'm making a basic dice app, and I'd like to display dice results in a FlowPane because it automatically adjusts the "columns" as the window is sized/resized horizontally. The problem with this solution is that the results need to be scrollable, and ScrollPane performance seems completely lackluster in Gluon on android.
Currently, for the desktop version (regular JavaFX) I use a FlowPane in a scroll pane, and for the mobile version I use a CharmListView. But I'd like to be able to use a good-performing grid on mobile, too.
I'd like to be able to have the image on the right be more like the one on the left, without destroying scrolling performance on mobile.
Does anyone know of any tools to do this without having to get the width of the window, calculate how many columns of dice I can have, and populating the CharmListView with HBoxes with the number of columns calculated?
Everything in my project is Gluon 3. I wonder if it just has a problem with a bunch of image boxes.
My code is roughly shaped like this:
private Image image1 = new Image("/Dice/one.png");
private Image image2 = new Image("/Dice/two.png");
private Image image3 = new Image("/Dice/three.png");
private Image image4 = new Image("/Dice/four.png");
private Image image5 = new Image("/Dice/five.png");
private Image image6 = new Image("/Dice/six.png");
ArrayList<Image> images = new ArrayList<>();
images.add(image1);
images.add(image2);
images.add(image3);
images.add(image4);
images.add(image5);
images.add(image6);
FlowPane pane = new FlowPane();
pane.prefWidthProperty().bind(widthProperty());
ScrollPane scrollPane = new ScrollPane(pane);
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
for(int i = 0; i < 1000; i++) {
pane.getChildren().add(new ImageView(images.get(random.nextInt(6))));
}
setCenter(scrollPane);'
This is all inside my basic view class. Performance is absolutely terrible, even with just around ~100 dice. I'm mostly making this for tabletop war games, and I play a horde army... so more than 100 dice is not uncommon for me. The devices I've done it on are reasonably high-end, too: Samsung Galaxy S7 and a Nexus 9.