我正在使用Starling框架开发一个应用程序,但我遇到了一个问题,这个应用程序在几乎所有类型的设备上都能工作,但是当我试图在Galaxy Tab 2中安装它时,会出现一些问题,因为默认的方向是景观,所以应用程序看起来完全没有条理。我试着用XML修改它,并添加一个事件来手动进行定向,但是它不起作用,所以我需要帮助。
我首先做的是这个
<aspectRatio>portrait</aspectRatio>
<autoOrients>false</autoOrients>
<fullScreen>true</fullScreen>
<visible>true</visible>在我试过这个之后
stage.setOrientation( StageOrientation.UPSIDE_DOWN );非常感谢!
发布于 2013-12-05 13:07:36
StageOrientation.UPSIDE_DOWN离StageOrientation.NORMAL有180度,所以如果正常是景观,那么倒挂也是颠倒的,有些设备不支持这一点。我建议用高度和宽度来确定绝对方向,而不是相对方向,并对此作出反应。
if (stage.width > stage.height)//we are in landscape
{
if(stage.orientation == StageOrientation.NORMAL || stage.deviceOrientation == StageOrientation.NORMAL)
{
stage.setOrientation(StageOrientation.ROTATED_LEFT);
}
else
{
stage.setOrientation(StageOrientation.NORMAL);
}
}另外,值得注意的是,stage.orientation和stage.deviceOrientation之间有一个区别,您可以更详细地了解到这一点-- 这里
https://stackoverflow.com/questions/20391009
复制相似问题