如何设置<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>
看看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>