Java 图像不';不要把按钮盖好
我无法正确调整图像的大小,使图像和按钮彼此适合 下面是代码的重要部分:Java 图像不';不要把按钮盖好,java,image,button,javafx,fxml,Java,Image,Button,Javafx,Fxml,我无法正确调整图像的大小,使图像和按钮彼此适合 下面是代码的重要部分: <Button prefHeight="80" prefWidth="80" id="LifeLine"> <shape> <javafx.scene.shape.Circle radius="1"/> </shape> </Button> 这是一个屏幕截图。最左上方的按钮就是问题所在。 编辑 现在我得到了一个按钮,上面有我发布的代码
<Button prefHeight="80" prefWidth="80" id="LifeLine">
<shape>
<javafx.scene.shape.Circle radius="1"/>
</shape>
</Button>
这是一个屏幕截图。最左上方的按钮就是问题所在。
编辑
现在我得到了一个按钮,上面有我发布的代码
将“背景重复”更改为“不重复”或删除该属性这不是完全正确的答案,因为按钮和图像之间仍有一个小间隙,但这是目前我能提供的最佳解决方案。带有此代码的图像现在位于按钮的中心,并且不再重复。现在我需要弄清楚为什么图像圈和按钮圈的大小不一样,尽管它们的高度和宽度都一样
<Button prefHeight="80" prefWidth="80" >
<shape>
<javafx.scene.shape.Circle radius="1" />
</shape>
<graphic>
<ImageView fitHeight="80" fitWidth="80" smooth="true" >
<image>
<Image url="@ImageFiles/AudienceButton.png"/>
</image>
</ImageView>
</graphic>
</Button>
更好的解决方案
<Button prefHeight="70" prefWidth="70" >
<shape>
<javafx.scene.shape.Circle radius="1" />
</shape>
<graphic>
<ImageView fitHeight="70" fitWidth="70" scaleX="1.2" scaleY="1.2" smooth="true" >
<image>
<Image url="@ImageFiles/AudienceButton.png"/>
</image>
</ImageView>
</graphic>
</Button>
我所要做的就是从x和y方向将图像缩放到按钮的大小。将css显示块设置为按钮,或内联-block@GiacomoPaita在我的CSS文件中,我可以做-fx显示插入符号:但是没有类似于-fx显示:内联块的东西;我可以使用。什么类型的CSS规则是-fx?@GiacomoPaita我应该说它是与javafx集成的CSS。我看到你编辑了你的问题:你最终解决了你的问题吗?
<Button prefHeight="70" prefWidth="70" >
<shape>
<javafx.scene.shape.Circle radius="1" />
</shape>
<graphic>
<ImageView fitHeight="70" fitWidth="70" scaleX="1.2" scaleY="1.2" smooth="true" >
<image>
<Image url="@ImageFiles/AudienceButton.png"/>
</image>
</ImageView>
</graphic>
</Button>