我已经创建了自己的(自定义)对话框。但是想要它的风格像原来的一样Alert Dialog . IE。底部有深色标题背景和灰色按钮背景。 是否有任何现成的 xml 具有相同的? (所以,我不会担心确切的颜色、高度、字体大小等)
最佳答案
此答案不正确
使用Theme.Dialog.Alert
来自 themes.xml :
<!-- Default theme for alert dialog windows, which is used by the
{@link android.app.AlertDialog} class. This is basically a dialog
but sets the background to empty so it can do two-tone backgrounds. -->
<style name="Theme.Dialog.Alert" parent="@android:style/Theme.Dialog">
<item name="windowBackground">@android:color/transparent</item>
<item name="windowTitleStyle">@android:style/DialogWindowTitle</item>
<item name="windowIsFloating">true</item>
<item name="windowContentOverlay">@null</item>
</style>
这可以在 XML 布局或 Android list 中应用,如 referenced here :
<activity android:theme="@android:style/Theme.Dialog.Alert">
或使用 setTheme(int)
进入 Activity .但是,这似乎不是推荐的做法。 bug report 中显示的简单示例代码.
关于android - 如何使自定义对话框看起来像警报对话框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5452382/