【发布时间】:2015-12-16 22:03:07
【问题描述】:
我在表格列中显示图像。缩放我使用的图像
image.fitWidthProperty().bind(col.widthProperty().subtract(40));
但如果图像宽度大于列宽,我需要一个仅缩放的解决方案。在其他情况下,我将使用原始图像宽度。
我怎么写?
【问题讨论】:
标签: javafx imageview width html-table scale
我在表格列中显示图像。缩放我使用的图像
image.fitWidthProperty().bind(col.widthProperty().subtract(40));
但如果图像宽度大于列宽,我需要一个仅缩放的解决方案。在其他情况下,我将使用原始图像宽度。
我怎么写?
【问题讨论】:
标签: javafx imageview width html-table scale
图像加载后,您可以通过在Image(而不是ImageView)上调用getWidth() 来获取其宽度。
那你就可以了
image.fitWidthProperty().bind(
Bindings.when(col.widthProperty().lessThan(imageWidth + 40))
.then(col.widthProperty().subtract(40))
.otherwise(imageWidth));
【讨论】: