有没有办法确定Android设备上AIR应用程序可用的实际区域?
例如,在Kindle Fire上 Capabilities.screenResolutionY 返回600,因为工具栏实际上是580左右。是否有可能以编程方式达到此值?
感谢。
答案 0 :(得分:2)
使用stage.stageHeight http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Stage.html#stageHeight
答案 1 :(得分:0)
这个问题是相对的。从硬件方面来看,600像素是可用的,因此应该预期结果。如果您正在为Kindle Fire进行编程,那么您是否只需要预测20像素工具栏并在需要时从结果中减去20?这取决于您的项目特定于Kindle Fire的假设。
答案 2 :(得分:0)
我觉得这个问题有点受限。 AIR代码可以(大部分)与平台无关,我建议在编程时允许这方面。考虑到这一点,这就像我可以找到一个通用的尺寸解决方案。
static public const DEVICE_UNK:int = 0;
static public const DEVICE_WINDOWS:int = 1;
static public const DEVICE_APPLE_IPAD:int = 2;
static public const DEVICE_ANDROID:int = 3;
public var deviceType:Number;
public var _fullWidth:Number;
public var _fullHeight:Number;
deviceType = -1;
if (Capabilities.manufacturer.toLowerCase().indexOf("windows") != -1)
{
deviceType = DEVICE_WINDOWS;
}
else if (Capabilities.manufacturer.toLowerCase().indexOf("android") != -1)
{
deviceType = DEVICE_ANDROID;
}
else if (Capabilities.manufacturer.toLowerCase().indexOf("ios") != -1)
{
deviceType = DEVICE_APPLE_IPAD;
}
else
{
deviceType = DEVICE_UNK;
}
然后使用deviceType
确定初始化,调整大小或其他任何内容的维度:
switch (deviceType)
{
case DEVICE_UNK:
case DEVICE_WINDOWS:
_fullWidth = stage.stageWidth;
_fullHeight = stage.stageHeight;
break;
case DEVICE_ANDROID:
case DEVICE_APPLE_IPAD:
_fullWidth = Math.max(stage.fullScreenWidth, stage.fullScreenHeight);
_fullHeight = Math.min(stage.fullScreenWidth, stage.fullScreenHeight);
break;
default:
trace("Error: invalid deviceType.");
break;
}
_fullWidth
和_fullHeight
是任何平台上可用空间的当前最大尺寸。
我希望对代码有任何改进。请不要进行代码优化;我正在寻找更好的方法来确定尺寸。如果您了解更多,请发表评论。