如何使自定义对话框看起来像警报对话框?
我创建了自己的(自定义)对话框。但希望其风格像原始警报对话框。即底部有深色标题背景和灰色按钮背景。 是否有任何现成的 xml 具有相同的功能? (所以,我不会担心确切的颜色、高度、字体大小等)
I've created my own (custom) Dialog. But would like to have its style like original Alert Dialog. I.e. with dark title background and grey buttons background on the bottom.
Is there any ready-for-use xml with the same? (so, I wouldn't worry about exact colors, heights, font sizes etc.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个答案不正确
Theme.Dialog.Alert
使用themes.xml:
然后可以将其应用到 XML 布局或 Android 清单中,如 < a href="http://developer.android.com/guide/topics/ui/themes.html" rel="nofollow">在此处引用:
或者使用
setTheme(int)
。然而,这似乎不是推荐的做法。此错误报告中显示了简单的示例代码。This answer is incorrect
Use
Theme.Dialog.Alert
From themes.xml:
This can then be applied within an XML layout or Android manifest, as referenced here:
Or onto an Activity using
setTheme(int)
. However, this does not seem to be a recommended practice. Simple sample code shown in this bug report.我也遇到了这个问题,想创建一个与AlertDialog具有相同UI的Activity。我发现有点困难。最后,我创建了一个透明的活动并在其中启动了一个AlertDialog来解决。
I also encountered this problem, wanted to create an Activity having the same UI as AlertDialog. I found it's a little difficult. Finally, I created a transparent activity and started an AlertDialog in it to resolve.