Android的screenorientation变化的所有活动 [英] Android screenorientation change for all activities
问题描述
我要修正我的Android应用程序为纵向屏幕方向。使用谷歌,我发现,这是可以做到通过添加以下code到我的manifest.xml:
I want to fix screen orientation on my android application to portrait. Using google, i've found, that this can be done by adding the following code to my manifest.xml:
<activity android:name=".LauncherActivity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait">
</activity>
这很好enougth,但问题是如下:我已经约15项活动,现在,这个数字将增长。有什么办法适用取向的所有活动一次?
That's fine enougth, but the problem is follows: i've about 15 activities now, and this number will grow. Is there any way to apply orientation to all activities at once?
我试图用样式的方式如下:
I tried to use styles in a following way:
theme.xml
theme.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Custom" parent="android:Theme">
<item name="android:screenOrientation">portrait</item>
<item name="android:windowBackground">@drawable/launcher</item>
<item name="android:configChanges">keyboardHidden|orientation</item>
</style>
</resources>
的Manifest.xml
Manifest.xml
<application ...
android:debuggable="true"
android:theme="@style/Custom"
>
//...
</application>
或
<activity
...
android:theme="@style/Custom"
>
//...
</activity>
这两个例子适用windowBackground成功地,但screenOrientation简化版,作品。任何想法?
Both the examples apply windowBackground succesfully, but screenOrientation does't works. Any ideas?
推荐答案
没办法。我需要重复
<activity android:name=".LauncherActivity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait">
</activity>
在每个&LT;活性gt;以清单
标记
这篇关于Android的screenorientation变化的所有活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!