java - 如何使 GridPane 中的 ImageView 图像可调整大小?
问题描述
我GridPane
在所有ImageView
包含图像的单元格中都有一个和。当我更改窗口大小时,我成功地GridPane
调整了大小。
问题是当GridPane
图像变大时,图像不会增长。我知道您可以通过以下方式使它们在全屏时适合:
imageView.setFitHeight(100);
imageView.setFitWidth(100);
使用此代码,图像在非全屏时会太大。
我想让它们在窗口模式下适合perfectly(Fit(80))
单元格,以及Fullscreen(Fit(100))
.
我的(不太好看)的想法是有一个类似的方法:
if(stage.inFullscreen) { setFitHeight/Width(100)};
if(stage.inWindowscreen) { setFitHeight/Width(80)};
还有其他更优雅的方式吗?
我的代码的一部分:
<GridPane fx:id="Board" layoutY="-1.0" prefHeight="800.0" prefWidth="836.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
...
解决方案
推荐阅读
- centos7 - Clearcase - 无法访问 VOB - ls:读取目录 - 权限被拒绝
- android - 如何在 viewpager 中使用 webview 的水平滚动?
- swift - 文本文件中的 Swift 转换格式(字符串解析)
- spring-boot - spring boot配置自定义sql
- c# - 如何获取列表框中所选项目的索引值?
- android - 使用 DownloadManager 下载视频文件时,应用程序在 Android 10 上崩溃
- php - SQL 查询将列数据的平均值转换为 JSON 用于 PHP 中的谷歌饼图
- java - 将 base 64 编码图像发送到 gmail
- excel - 在 Power BI 中的列中计算周期数
- build - 如何使用标准 Azure Devops DotNet 构建任务获取二进制日志,并将其作为带有 YAML 构建的工件附加到构建中?