简体   繁体   English

如何针对不同屏幕尺寸缩放应用程序?

[英]How to scale application for different screen sizes?

I am looking for a robust way to scale my AIR for Android app up, or down, for different screen sizes. 我正在寻找一种健壮的方法来针对不同的屏幕尺寸上下缩放我的AIR for Android应用程序。

The app is going to be published privately, and will only likely ever sit on devices with a very small range of resolutions (720 or 1080p typically) 该应用将要私下发布,并且只能安装在分辨率范围很小(通常为720或1080p)的设备上

Now, firstly, I read that you cannot change the stage height and width dynamically and can only be set once in the application settings. 现在,首先,我读到您不能动态更改载物台的高度和宽度,只能在应用程序设置中设置一次。 So first off, do I set my app to have the largest resolution, 1080p, and scale down. 因此,首先,我是否将我的应用设置为具有最高分辨率1080p并缩小比例。 Or do I set it to a mid ground between 1080 and 720 and let it scale up and down? 还是将其设置在1080到720之间的中间位置,并让它向上和向下缩放?

Secondly, how should I scale it? 其次,我应该如何缩放它? Should I use Stage.scaleMode and if so, which mode? 我应该使用Stage.scaleMode ,如果使用的是哪种模式?

How do I scale the app if I cannot resize the stage directly? 如果无法直接调整舞台大小,如何缩放应用程序?

I have looked at the following pages, but they don't seem to work very well, if at all, for some odd reason? 我看了以下几页,但由于某种奇怪的原因,它们似乎工作得不好,如果有的话?

link 1 link 2 link 3 link 4 链接1 链接2 链接3 链接4

You can do everything dynamically! 您可以动态地做所有事情!

use: 采用:

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT

and handle it yourself when the application starts. 并在应用程序启动时自行处理。 By useing relative values instead of fixed pixels, to position your items 通过使用相对值而不是固定像素来放置物品

To get the devices dimensions and DPI use: 要获取设备尺寸和DPI,请使用:

Capabilities.screenResolutionX;
Capabilities.screenResolutionY;
Capabilities.screenDPI;

If you're useing Bitmaps dont let them scale too much, and rather down then up. 如果您使用的是位图,请不要让它们缩放过多,而是先降后升。 Also checkout .smoothing attribute for Bitmaps. 还要为位图检出.smoothing属性。 its best to have different size bitmaps ready and replace them according to your screensize in some startup method. 最好准备好不同大小的位图,并在某些启动方法中根据您的屏幕尺寸替换它们。

the second link u postet acutally explains all this very well Postet的第二个链接对所有这些都做了很好的解释

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

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