固定对话框视图上的屏幕方向 [英] Fix orientation of screen on Dialog view

查看:103
本文介绍了固定对话框视图上的屏幕方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在活动中使用了自定义对话框.我想仅在对话框显示在其他位置时才设置屏幕方向,屏幕方向可以更改为纵向或横向.有什么方法可以专门针对这种特殊情况在Java代码中定位.

I am using a custom dialog in my activity. I want to set the screen orientation only if the dialog is shown elsewhere the screen orientation can change to portrait to landscape vice versa. Is there any way to fix the orientation for such particular case specifically in java code.

推荐答案

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
//Show dialog here
//...
//Hide dialog here
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);

这篇关于固定对话框视图上的屏幕方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆