力"人像"方向模式人像、方向、模式、QUOT

由网友(人生自编自导自演)分享简介:我试图迫使肖像模式,为我的应用程序,因为我的应用程序是绝对不适合的风景模式。I'm trying to force the "portrait" mode for my application because my application is absolutely not designed for the "lan...

我试图迫使肖像模式,为我的应用程序,因为我的应用程序是绝对不适合的风景模式。

I'm trying to force the "portrait" mode for my application because my application is absolutely not designed for the "landscape" mode.

阅读一些论坛上后,我在清单文件中添加如下几行:

After reading some forums, I added these lines in my manifest file:

<application 
  android:debuggable="true"
  android:icon="@drawable/icon" 
  android:label="@string/app_name"
  android:screenOrientation="portrait">

不过,我的设备(HTC Desire的)上不起作用。它从切换肖像LO风景,而忽略从清单文件中的行。

But it doesn't work on my device (HTC Desire). It switches from "portrait" lo "landscape", ignoring the lines from the manifest file.

在多个论坛上看书,我尝试添加这在我的清单文件:

After more forums reading, I tried to add this in my manifest file:

<application 
  android:debuggable="true"
  android:icon="@drawable/icon" 
  android:label="@string/app_name"
  android:configChanges="orientation"       
  android:screenOrientation="portrait">

和我在活动课这样的功能:

and this function in my activity class:

public void onConfigurationChanged(Configuration newConfig)
{
    super.onConfigurationChanged(newConfig);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}

但同样,没有运气。因此,任何人有一个想法?

But again, no luck. So, anybody has an idea?

在此先感谢!

推荐答案

请勿定向到应用程序元素,相反,你应该将属性应用到活动元素,还必须设置 configChanges 如下所述。

Don't apply the orientation to the application element, instead you should apply the attribute to the activity element, and you must also set configChanges as noted below.

例如:

<activity
   android:screenOrientation="portrait"
   android:configChanges="orientation|keyboardHidden">
</activity>

这是在清单文件应用,例如, /platforms/android/AndroidManifest.xml

This is applied in the manifest file at, for example, /platforms/android/AndroidManifest.xml.

阅读全文

相关推荐

最新文章