[英]How to rotate the screen to landscape (or portrait) by programmable way?
How to rotate the screen to landscape (or portrait) by programmable way? 如何通过可编程方式将屏幕旋转为横向(或纵向)? I am trying to make it independent when user rotates the screen.
我试图在用户旋转屏幕时使其独立。
Is it possible thing ? 有可能吗?
Thanks in advance. 提前致谢。
You can try with the sample below... 您可以尝试下面的示例...
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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.