【问题标题】:Image rounded button JavaFX图像圆形按钮 JavaFX
【发布时间】:2017-03-19 20:47:45
【问题描述】:

我正在使用圆形按钮,我想在里面放一张图片。问题是图像在中心而不是在左边,即使调用了

loadButton.setAlignment(Pos.BASELINE_LEFT);

我得到的是上面的按钮,我需要的是下面的按钮。您知道在圆角下显示 png 的任何方法吗?

   final Label response = new Label();
    final ImageView imageView = new ImageView(
            new Image("recordbutton.png")
    );
    imageView.setFitHeight(40);
    imageView.setFitWidth(40);

    loadButton.setGraphic(imageView);
    loadButton.setStyle("-fx-base: coral;");
    loadButton.setContentDisplay(ContentDisplay.LEFT);
    loadButton.setStyle(
             "-fx-background-radius: 100em; " +
                    "-fx-min-width: 60px; " +
                    "-fx-min-height: 60px; " +
                    "-fx-max-width: 130px; " +
                    "-fx-max-height: 60px;"
    );

非常感谢!

【问题讨论】:

    标签: css image button javafx


    【解决方案1】:

    而不是:

    loadButton.setContentDisplay(ContentDisplay.LEFT);
    

    使用:

    loadButton.setAlignment(Pos.CENTER_LEFT);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-24
      • 1970-01-01
      • 2011-12-20
      • 2021-10-08
      相关资源
      最近更新 更多