使用样式设置活动的屏幕方向

问题描述:

我想用一个样式设置活动屏幕方向:

I'm trying to set activity screen orientation using a styles:

下面是styles.xml:

Here is the styles.xml:

...
<style name="Some.Activity" parent="android:Theme">
  <item name="android:screenOrientation">portrait</item>
</style>
...

这里是活动的声明在AndroidManifest.xml中:

and here is activity declaration in AndroidManifest.xml:

<activity android:name="SomeActivity" android:theme="@style/Some.Activity"/>

和它不工作。
我知道我可以只设置

and it doesn't work.
I know that I can just set

<activity android:name="SomeActivity" android:theme="@style/Some.Activity"
    android:screenOrientation="..."/>

在清单中,但其对我很重要,使用一个主题做的。照片 想法?

in the manifest, but its important to me to do that using a theme.
Ideas?

的http:// developer.android.com/guide/practices/screens_support.html

该链接可能会有帮助。基本上,你必须做出不同的布局文件,对于每个方向,并把它们放在相应的布局,土地或布局端口的文件夹。您还可以创建布局在不同的屏幕尺寸不同的方向。举例来说,如果不是你有一个小屏幕,你可以创建一个名为布局小土地文件夹,还有一个自定义的布局文件,一个正常的大屏幕在横向模式下配合控件

This link may help. Basically you have to make different layout files for each orientation and put them in corresponding layout-land or layout-port folders. You can also create layouts for different orientations on different screen sizes. For example, if not all of the controls you have for a "normal" sized screen in landscape mode fit on a small screen you can create a folder named layout-small-land and have another customized layout file.