欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

Android 屏幕实现上下翻转

程序员文章站 2023-01-26 20:15:54
android 屏幕实现上下翻转 通常我们的应用只会设计成横屏或者竖屏,锁定横屏或竖屏的方法是在manifest.xml文件中设定属性android:screenorie...

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竖屏根据重力上下翻转。

如果有兴趣,你也可以试试其他的值哦...

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!