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

android:name="com.example.kata1.MainActivity"

android:label="@string/app_name"

android:screenOrientation="landscape">

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

android:screenOrientation = ["unspecified" | "behind" |

"landscape" | "portrait" |

"reverseLandscape" | "reversePortrait" |

"sensorLandscape" | "sensorPortrait" |

"userLandscape" | "userPortrait" |

"sensor" | "fullSensor" | "nosensor" |

"user" | "fullUser" | "locked"]

其中sensorLandscape就是横屏根据重力上下翻转,sensorPortrait竖屏根据重力上下翻转。

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

原文:http://www.cnblogs.com/ADaii/p/3835245.html

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐