以编程方式在整个Android应用程序中禁用屏幕旋转 [英] Programmatically disabling screen rotations in the entire Android application

查看:585
本文介绍了以编程方式在整个Android应用程序中禁用屏幕旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以编程方式禁用整个Android应用程序的屏幕旋转?

How do I programmatically disable screen rotations for an entire Android application?

推荐答案

无论以哪种方式倾斜设备,都保持纵向或横向. 您需要将此添加到您要限制的活动内的清单中

As in keep it in portrait or Landscape no matter which way device is tilted? You need to add this to your manifest inside the activity that you want to limit

 android:screenOrientation="portrait" //Or landscape for horizontal.

如果您希望活动之间有所不同,只需使清单看起来像这样.

If you want it different between activities just make your manifest look like this.

        <activity android:name=".Activity1" 
        android:screenOrientation="landscape">       
        </activity>

        <activity android:name=".Activity2" 
        android:screenOrientation="portrait">
        </activity>

        <activity android:name=".Activity3" 
        android:screenOrientation="landscape">
        </activity>

这篇关于以编程方式在整个Android应用程序中禁用屏幕旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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