如何设置仅纵向的对话框?
有没有办法始终以纵向方式显示对话框?我需要它是因为它的布局。
我知道我可以为活动设置它,
android:screenOrientation="portrait|reversePortrait"
但是对话框呢?
Is there a way to showing a dialog always in portrait? I need that because of its layout.
I know that I can set that for an Activity with
android:screenOrientation="portrait|reversePortrait"
But what about a dialog?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
显示对话框时,检查设备的方向。
At the time of the dialog showing, check the device's orientation.
不确定这些方法是否适合您的要求,
一种方法是将活动显示为屏幕方向设置为纵向的对话框(带有对话框主题)
参考
ApiDemos
中的DialogActivity
另一种方法是强制 Activity 改变其方向,
并在
onConfigurationChanged()
中打开对话框(带有一些逻辑)。Not sure these ways will fit your requirement ,
One way is showing Activity as a dialog with screen orientation set to portrait (with dialog theme)
refer
DialogActivity
fromApiDemos
Other way is forcing activity to change its orientation by
and open dialog in
onConfigurationChanged()
(with some logic).