java - 无法更改低于某个最小值的按钮宽度
问题描述
我有这个代码:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ToggleButton;
import javafx.scene.image.Image;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundImage;
import javafx.scene.layout.BackgroundSize;
import javafx.scene.layout.TilePane;
import javafx.stage.Stage;
public class ToggleButtonSize extends Application {
@Override
public void start(Stage stage) throws Exception {
var toggleButton = new ToggleButton();
toggleButton.setMaxHeight(10);
toggleButton.setMaxWidth(10);
// tried also
toggleButton.setStyle("-fx-max-width: 10; -fx-pref-width: 10;");
var pane = new FlowPane(toggleButton);
var scene = new Scene(pane);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
此代码工作正常,但是当我使用 MobileApplication 时,最小宽度不会达到 10:
使用应用程序时如何缩小尺寸?
解决方案
推荐阅读
- jenkins - GitHub 拉取请求生成器插件的问题
- php - 是否有 PHP 简写: if (a) {var = a}
- typescript - 如何使用 typeorm 将可为空的数据库字段设置为 NULL?
- python - 格式字符串的参数太多
- tensorflow - 旧 CPU 上的 tfjs-node(没有 AVX)
- embedded-linux - /dev/mem 或用户空间突发传输;如何获得更快的 /dev/mem 访问
- javascript - 可以在服务器端发出 POST 请求吗?
- android - 应用程序休眠时 Xamarin AlarmManager 未触发
- apache-spark - Spark 3.0.1 Dataframe Operations 工作,但 Spark SQL 没有
- python - Pytorch RuntimeError:预期的标量类型 Float 但找到了字节