如何设置ImageView的边距和填充?

如何设置<ImageView>的边距和填充?

我做了fx-padding: 50px;fx-margin: 50px;,但没有用。

我的代码:

<ImageView style="fx-padding: 50px; fx-margin: 50px;"
    fitHeight="120" fitWidth="120" fx:id="image" onmousepressed="#mousepressed">
</ImageView>
iCMS 回答:如何设置ImageView的边距和填充?

看看property list of ImageView;没有这样的属性或任何可以使您达到类似效果的属性。您可能可以使用父布局的布局参数来实现效果;如果不可能的话;您需要将ImageView包装在确实允许这种布局的布局中,例如:

<StackPane maxHeight="-Infinity" maxWidth="-Infinity"> <!-- use the preferred size for max size constraints -->
    <padding>
        <Insets topRightBottomLeft="50" />
    </padding>
    <children>
        <ImageView fitHeight="120" fitWidth="120" fx:id="image" onMousePressed="#mousePressed"/>
    </children>
</StackPane>
本文链接:https://www.f2er.com/2174211.html

大家都在问