我想按照下面的代码将图像添加到javafx2 gridpane,但我希望这个图像不受其单元格的限制。我希望图像基本上流出细胞。
GridPane moon_pane = new GridPane();
moon_pane.setId("prayertime_pane");
moon_pane.setGridLinesVisible(true);
moon_pane.setPadding(new Insets(10, 10, 10, 10));
moon_pane.setAlignment(Pos.BASELINE_CENTER);
moon_pane.setVgap(10);
moon_pane.setHgap(10);
Text moon_phase_text = new Text("60% full");
moon_phase_text.setId("prayer-text-english");
moon_pane.setHalignment(moon_phase_text,HPos.LEFT);
moon_pane.setValignment(moon_phase_text,VPos.CENTER);
moon_pane.setConstraints(moon_phase_text, 0, 0);
moon_pane.getChildren().add(moon_phase_text);
ImageView Moon_img = new ImageView(new Image(getClass().getResourceAsStream("/Images/Full_Moon.png")));
// moon_pane.setHalignment(Moon_img,HPos.CENTER);
// moon_pane.setValignment(Moon_img,VPos.CENTER);
Moon_img.setFitWidth(100);
Moon_img.setFitHeight(100);
moon_pane.add(Moon_img, 1, 0);
Text next_moon_text = new Text("13/02");
next_moon_text.setId("prayer-text-english");
moon_pane.setHalignment(next_moon_text,HPos.LEFT);
moon_pane.setValignment(next_moon_text,VPos.CENTER);
moon_pane.setConstraints(next_moon_text, 2, 0);
moon_pane.getChildren().add(next_moon_text);
答案 0 :(得分:0)
您可以尝试在ImageView节点上增加比例。我认为缩放与布局/调整大小分开。