AIR - 设置 NativeWindow 的大小以包括系统镶边
如何找出系统镶边的大小,以便我可以指定窗口大小以达到我想要的舞台大小?
如果我的主窗口设置为 800 x 600(舞台),并且我创建如下第二个窗口,它会更小。
public function Main():void
{
var windowOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
windowOptions.systemChrome = NativeWindowSystemChrome.STANDARD;
windowOptions.type = NativeWindowType.NORMAL;
var newWindow:NativeWindow = new NativeWindow( windowOptions );
newWindow.width = 800;
newWindow.height = 600;
newWindow.stage.scaleMode = StageScaleMode.NO_SCALE;
newWindow.stage.align = StageAlign.TOP_LEFT;
newWindow.activate();
}
我假设您增加了 newWindow.width = 800;
和 newWindow.height = 600;
以考虑到 chrome,但是您如何找到这个值?
How do you find out the size of the system chrome so that I can specify the window size to achieve the stage size I want?
If my main window is set at 800 x 600 (stage), and I create a second window as below, it will be smaller.
public function Main():void
{
var windowOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
windowOptions.systemChrome = NativeWindowSystemChrome.STANDARD;
windowOptions.type = NativeWindowType.NORMAL;
var newWindow:NativeWindow = new NativeWindow( windowOptions );
newWindow.width = 800;
newWindow.height = 600;
newWindow.stage.scaleMode = StageScaleMode.NO_SCALE;
newWindow.stage.align = StageAlign.TOP_LEFT;
newWindow.activate();
}
I assume you increase both newWindow.width = 800;
and newWindow.height = 600;
to account for the chrome, but how do you find this value?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以通过将窗口大小(包括镶边)减去内部尺寸(不包括镶边)来计算镶边的尺寸。
来自 NativeWindows 的 宽度 帮助:
因此内部尺寸可以通过 stage object< 获得/a> ( stage.stageWidth 和 stage.stageHeight: )
因此:
you can calculate the size of the chrome by substracting the windows size (that include the chrome) with the inner size (that exclude the chrome).
From the width help of NativeWindows :
So the inner size can be obtained with stage object ( stage.stageWidth and stage.stageHeight: )
hence :
使用 NO_SCALE 创建 ActionScript 项目时,stage.stageHeight 和 stage.stageWidth 不能用于计算主应用程序窗口中的镶边,因为它们不会调整大小以符合内部宽度。您必须引用主窗口阶段。
要查找主窗口内部舞台的高度和宽度,您可以使用 stage.nativeWindow.stage 引用 stageHeight 和 stageWidth 属性来提供内部宽度。
例如,对于 1280x720 所需的内部尺寸:
When creating ActionScript projects with NO_SCALE the stage.stageHeight and stage.stageWidth cannot be used to calculate chrome in the main application window as they do not resize to conform to the inner width. You must reference the main window stage.
To find the main windows inner stage height and width you can use the stage.nativeWindow.stage references stageHeight and stageWidth properties which gives inner width.
e.g. for a 1280x720 desired inner size:
仅供参考,我觉得其他答案还不够清楚。要将新窗口设置为所需的尺寸:
For reference, as I feel the other answers aren't clear enough. To set a new window to the desired dimensions: