android – 如何通过可编程方式将屏幕旋转到横向(或纵向)?

如何通过可编程方式将屏幕旋转为横向(或纵向)?
我试图在用户旋转屏幕时使其独立.

这可能吗?

提前致谢.

解决方法

您可以尝试下面的示例…
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
    // You can set the value initially by
    // ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED. Once set it
    // retains it's value. The View will be rendered in the specified
    // orientation using the code below.
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}

相关文章

Android 通过adb shell命令查看内存,CPU,启动时间,电量等...
Monkey Android app稳定性测试工具之Monkey使用教程 by:授客...
Android 常见adb命令 by:授客 QQ:1033553122 1、 查看所有已...
这篇“android轻量级无侵入式管理数据库自动升级组件怎么实现...
今天小编给大家分享一下Android实现自定义圆形进度条的常用方...
这篇文章主要讲解了“Android如何解决字符对齐问题”,文中的...