全屏显示对话框

Showing dialog as fullscreen

我试图在较小的设备上获得全屏对话框,在较大的设备上获得普通对话框。

来自 Android 文档:http://developer.android.com/guide/topics/ui/dialogs.html

Showing an activity as a dialog on large screens

Instead of showing a dialog as a fullscreen UI when on small screens, you can accomplish the same result by showing an Activity as a dialog when on large screens. Which approach you choose depends on your app design, but showing an activity as a dialog is often useful when your app is already designed for small screens and you'd like to improve the experience on tablets by showing a short-lived activity as a dialog.

To show an activity as a dialog only when on large screens, apply the Theme.Holo.DialogWhenLarge theme to the manifest element:

For more information about styling your activities with themes, see the Styles and Themes guide.

所以我有一个 activity 而不是真正的对话。 activity 在 phone 上看起来很棒。最重要的部分是 activity 有一个带有菜单按钮的操作栏。

当我在更大的设备上启动 activity 时,activity 确实显示为一个对话框,但是操作栏以及操作栏中的菜单项被删除了。

这是我使用的样式:

<style name="dialog_theme" parent="@style/Theme.AppCompat.DialogWhenLarge">
</style>

对话框不支持操作栏....真可惜。

但是,对话框确实支持工具栏。我能够使用工具栏在全屏 activity 和显示为对话框的 activity 中获得一致的外观和感觉。