[英]JavaFX Clipping an ImageView to an Ellipse within an AnchorPane
[英]Javafx resize ImageView to AnchorPane
我在 AnchorPane 中有一个 ImageView,我想按照与 AnchorPane 调整大小相同的命题调整图像大小。
有人可以解释我该怎么做吗?
提前谢谢了。
您可以将图像视图的fitWidth
和fitHeight
属性绑定到锚点窗格的宽度和高度:
imageView.fitWidthProperty().bind(anchorPane.widthProperty());
imageView.fitHeightProperty().bind(anchorPane.heightProperty());
如果您还想保留正在显示的图像的比例,您可以这样做
imageView.setPreserveRatio(true);
唯一对我有用的东西。 在视图上,监听 AnchorPane 的变化并设置 ImageView Size
init {
myAnchorPane.widthProperty().addListener { observable, oldValue, newValue ->
myImageView.fitWidth = myAnchorPane.width
myImageView.fitHeight = 0.0
}
}
看到这个答案。 基本上,您可以使用可以包含在项目中的ImageViewPane
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.