android 手机设置屏幕旋转

通常我们的应用只会设计成横屏或者竖屏,锁定横屏或竖屏的方法是在manifest.xml文件中设定属性android:screenOrientation为"landscape"(横屏)或"portrait"(竖屏):

 
        <activity
            android:name="com.example.kata1.MainActivity"
            android:label="@string/app_name" 
            android:screenOrientation="landscape">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
 
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

其实screenOrientation还可以设置成很多值:

android:screenOrientation       =         ["unspecified" | "behind" |
                                     "landscape" | "portrait" |
                                     "reverseLandscape" | "reversePortrait" |
                                     "sensorLandscape" | "sensorPortrait" |
                                     "userLandscape" | "userPortrait" |
                                     "sensor" | "fullSensor" | "nosensor" |
                                     "user" | "fullUser" | "locked"]
 
其中sensorLandscape就是横屏根据重力上下翻转,sensorPortrait竖屏根据重力上下翻转。
 
参考处:http://blog.csdn.net/oracleot/article/details/19045011
 
posted @ 2017-12-26 16:59  且说且梦  阅读(2935)  评论(0)    收藏  举报