小编use*_*374的帖子

JavaFx ImageView 不会在 fitWidthProperty 绑定到 VBox 时调整大小

我正在尝试重新调整图像大小,使其适合(缩放)在 a 分配的空间中SplitPane(有关解决方法的建议:该图像在运行程序时会发生变化,它应该从文本生成)。我当前使用的 ImageView 更改了SplitPane Divider. 分隔线永远不会导致ImageView缩小超过图像的大小。

两张图片显示了这种行为

ImageViewfitWidthProperty链接到 aVBox并没有给我预期的调整大小行为。增加ImageView的大小确实有效(它在没有绑定的情况下固定),但图像永远不会增长,它只是在它周围有边框。

我的 MWE:

sample.fxml

<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<SplitPane orientation="HORIZONTAL" xmlns:fx="http://javafx.com/fxml">
    <TextArea fx:id="textArea"/>
    <VBox fx:id="vBox" alignment="CENTER">
        <HBox fx:id="hBox" alignment="CENTER">
            <ImageView fx:id="imageView"/>
        </HBox>
    </VBox>
</SplitPane>
Run Code Online (Sandbox Code Playgroud)

Controller.java

import javafx.fxml.FXML;
import javafx.scene.control.TextArea;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;

public class Controller {
    @FXML
    private TextArea textArea = new TextArea();
    @FXML
    private …
Run Code Online (Sandbox Code Playgroud)

javafx imageview java-8 fxml splitpane

5
推荐指数
1
解决办法
2753
查看次数

标签 统计

fxml ×1

imageview ×1

java-8 ×1

javafx ×1

splitpane ×1