0

I'm using FXML. I have a GridPane (6x7) and inside of that I have a HBox (at 2,2 grid position). In that HBox I have 10 ImageView. I want to display 10 images taking equal space, and without crossing the grid. How to do this as relative sizing? Here are the screenshots.

What I want

What I want

How it is appearing

How it is appearing

ItachiUchiha
  • 36,135
  • 10
  • 122
  • 176
  • Can you please explain what do you mean by "I want to display 10 images taking equal space, and without crossing the grid". The images are inside the grid, how will they cross the grid? Please provide additional information, if possible with visual presentation of what you want. – ItachiUchiha Feb 20 '18 at 07:27
  • @Heman Kundu you mean to fit in that specific cell like a grid or enlarge the cell to fit all images or shrink the images to fit in a row? – Sunflame Feb 20 '18 at 11:21
  • @Sunflame Yes, resize the image to fit in that cell only. And when I am resizing the the window, images should also be resized too. Like relative size. And note that I have HBox containing those ImageViews. – Heman Kundu Feb 20 '18 at 13:30
  • Have you tried to bind every image's width to the hBox's withdProperty divided by nr of images? – Sunflame Feb 20 '18 at 14:02
  • I did this. `for(int i=0;i<10;i++){ ImageViewArray.get(i).setPreserveRatio(false); ImageViewArray.get(i).fitWidthProperty().bind(hbox.widthProperty()); ImageViewArray.fitHeightProperty().bind(hbox.heightProperty()); }` But didn't work. – Heman Kundu Feb 20 '18 at 14:53
  • You should divide ImageViewArray.get(i).fitWidthProperty().bind(hbox.widthProperty()); this with the number of images like: ImageViewArray.get(i).fitWidthProperty().bind(hbox.widthProperty().divide(10)); – Sunflame Feb 20 '18 at 15:22
  • @Sunflame No, tried this same result. Still not working. I think ImageViews are fitting properly in HBox, but what about the HBox fitting in GridPane cell? – Heman Kundu Feb 20 '18 at 16:28
  • Can you post your code? Surely what will happen is that the column containing the `HBox` will simply expand so it will be able to contain the `HBox` (with all its images). Why do you think the `HBox` is not fitting inside its grid cell? – James_D Feb 20 '18 at 17:39
  • Picture 2 is showing that the `HBox` is going out of cell 2,2. Actually I want to resize the `HBox` and as well as `ImageView`s depending on `GridPane`'s size, So that I can have more `HBox` and `VBox` in other cells and they don't overlap.(..not like this [See this ScreenShot](https://imgur.com/a/0mab7) ) – Heman Kundu Feb 20 '18 at 18:52

0 Answers0