简体   繁体   English

Adobe Air Desktop App约束窗口大小

[英]Adobe Air Desktop App Constrain window size

I have an Adobe Air app that runs on Mac and PC. 我有一个在Mac和PC上运行的Adobe Air应用程序。 (coded in AS3) However, the app has the dimensions of 540 by 960. I have content hidden off the visible stage however if the user resizes the window my content to the side shows and looks really funny. (在AS3中编码)但是,应用程序的尺寸为540乘960.我的内容隐藏在可见的舞台之外,但是如果用户调整窗口大小,我的内容显示在旁边,看起来非常有趣。

Is there a way to block the user from resizing the app window container? 有没有办法阻止用户调整应用程序窗口容器的大小?

I know I can remove the window but then they can't drag the app across screen or minimize it if they want. 我知道我可以删除窗口但是他们不能在屏幕上拖动应用程序或者如果他们想要的话最小化它。 THERE HAS.. to be an easy way to block them from resizing. 有...是阻止他们调整大小的简单方法。

Thanks for the tips. 谢谢你的提示。

I Found the answer. 我找到了答案。 :) :)

<application....>
    <!-- Normal app stuff like id, name, etc -->
    <initialWindow>
        <!-- Normal initialWindow stuff like content, title, systemChrome -->
        <minimizable>true</minimizable>
        <maximizable>false</maximizable>
        <resizable>false</resizable>
        <width>800</width>
        <height>600</height>
    </initialWindow>
</application>

Answer found here: In AIR, how do you create a windowed application that's not resizable? 在这里找到的答案: 在AIR中,如何创建一个不可调整大小的窗口应用程序?

You can actually leave the window resizable and set the max size for the window. 您实际上可以使窗口可调整大小并设置窗口的最大大小。 This allows your user to resize it to be smaller than your content etc. 这允许您的用户将其调整为小于您的内容等。

... 
<initialWindow>
    <minimizable>true</minimizable>
    <maximizable>false</maximizable>
    <resizable>true</resizable>
    <width>800</width>
    <height>600</height>

    <maxSize>800 600</maxSize>

    ...
</initialWindow>

See here for more information on the elements: http://help.adobe.com/en_US/air/build/WSfffb011ac560372f2fea1812938a6e463-8000.html#WSfffb011ac560372f2fea1812938a6e463-7fe7 有关这些元素的更多信息,请参见此处: http//help.adobe.com/zh_CN/air/build/WSfffb011ac560372f2fea1812938a6e463-8000.html#WSfffb011ac560372f2fea1812938a6e463-7fe7

To change the dimensions of the window programmatically you need to use the NativeWindow reference from the stage: 要以编程方式更改窗口的尺寸,您需要使用舞台中的NativeWindow引用:

import flash.display.NativeWindow;

// Simple validity check
if (stage && stage.nativeWindow)
{
    stage.nativeWindow.width = SOME_WIDTH;
    stage.nativeWindow.height = SOME_HEIGHT;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM