Android的screenorientation变化的所有活动 [英] Android screenorientation change for all activities

查看:370
本文介绍了Android的screenorientation变化的所有活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要修正我的Andr​​oid应用程序为纵向屏幕方向。使用谷歌,我发现,这是可以做到通过添加以下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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆