android:screenOrientation属性

这个android:screenOrientation我很少用到. 模模糊糊又没啥概念,今天看了一个项目用到了. 百度下记录下吧 .

在配置文件中的使用方法如下:

<activity
            android:name=".AppStart"
            android:label="@string/app_name"
            android:screenOrientation="portrait"//设置 该页面 只能 竖直屏幕方向显示 
            android:theme="@style/Theme.AppStartLoad">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
</activity>

还有其他几个值,但是如果用翻译软件去翻译的话.绝对把你搞蒙了.

android:screenOrientation="" 这句话默认不写的话,其实就是android:screenOrientation="unspecified"
这是一个默认值,有系统选择显示方向,在不同的设备上可能结果不太一样.
android:screenOrientation="landscape"  横向屏幕
android:screenOrientation="portrait"   竖向屏幕
android:screenOrientation="user"       用户当前首选方向
android:screenOrientation="behind"     与在活动/Activity堆栈下的Activity方向相同
android:screenOrientation="sensor"     根据物理方向传感器 来确定方向,比如有的游戏既支持竖屏也支持横屏,取决于用户手持方向.
android:screenOrientation="nosensor"   不随 物理方向传感器确定方向,该传感器呗忽略,所以当用户转动设备,显示不会跟随改变,除了这个区别. 这个怎么理解呢? 其实可以理解成系统关闭重力感应.


原文地址:https://www.cnblogs.com/android-zcq/p/5881664.html