【发布时间】:2020-06-28 12:17:01
【问题描述】:
gluon-mobile 视图大小调整 FXML 时遇到问题,我很困惑它使用不同的大小。
- 在 gluon-mobile 示例中,它使用 350 x 高度 600。
- 但在场景构建器文件-> 新模板中创建 335 x 高度 600 两个模板。
我需要它来设置我的 Adobe XD 来设计背景图像。
可以指定吗?
【问题讨论】:
标签: gluon-mobile
gluon-mobile 视图大小调整 FXML 时遇到问题,我很困惑它使用不同的大小。
我需要它来设置我的 Adobe XD 来设计背景图像。
可以指定吗?
【问题讨论】:
标签: gluon-mobile
这些尺寸(350x600、335x600)仅供参考,并根据通常的移动格式在桌面上进行测试,但实际尺寸将由真实设备定义,并且可能会有所不同。
例如参见https://material.io/tools/devices/,您可以在其中找到多款 360x640 dp 的设备,但也可以找到许多其他分辨率。
当您在真实设备上使用Gluon Mobile 显示您的视图时,场景将采用完整的可用大小。
如果你想检索这个值,你可以使用DisplayService(见doc):
Services.get(DisplayService.class).ifPresent(service -> {
// screen resolution of the device, in pixels
Dimension2D resolution = service.getScreenResolution();
System.out.printf("Screen resolution: %.0fx%.0f", resolution.getWidth(), resolution.getHeight());
// default screen dimensions of a mobile device, in dp
Dimension2D dimensions = service.getDefaultDimensions();
System.out.printf("Screen dimensions: %.0fx%.0f", dimensions.getWidth(), dimensions.getHeight());
});
如果您想使用图片作为背景,您可以使用 css 将其设置为正确扩展或调整为最终大小,如 here 为 -fx-background-image 记录的那样。
【讨论】:
好的,这意味着我需要各种尺寸的导出设计 img,比如
【讨论】: