Issue
How to set the margin and the padding of an <ImageView>
?
I did fx-padding: 50px;
and fx-margin: 50px;
but it doesn't work.
My code :
<ImageView style="fx-padding: 50px; fx-margin: 50px;"
fitHeight="120" fitWidth="120" fx:id="image" onMousePressed="#mousePressed">
</ImageView>
Solution
Take a look at the property list of ImageView
; there is no such property or any property that would allow you to achieve a similar effect. You may be able to use the layout parameters of the parent layout to achieve the effect; If this is impossible; you need to wrap the ImageView
in a layout that does permit this, e.g.:
<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>
Answered By - fabian