安卓:AlertDialogs的简单的定制 [英] Android: Simple customization of AlertDialogs
问题描述
我看了很多文章,这里和其他地方有关自定义AlertDialogs,和那些AlertDialog.Builder创建。
I have read lots of articles, here and elsewhere about customizing AlertDialogs, and those created by AlertDialog.Builder.
这是我目前使用的这种方法是注入我的一个ContextThemeWrapper AlertDialog.Builder。这ContextThemeWrapper配置为从从Theme.Dialog继承的自定义风格的阅读。
The approach that I'm using at the moment is injecting my AlertDialog.Builder with a ContextThemeWrapper. This ContextThemeWrapper is configured to read from a custom style that inherits from Theme.Dialog.
我的定制需求是相当简单:
My customization requirements are quite straightforward:
- 从默认的海军更改标题栏的背景颜色/黑色版
- 更改标题都和按键的字体类型和大小
我已经在默认的themes.xml和styles.xml看看,但我看不出哪里特别配置1号...有人可以让我知道如何做到这一点?
I've had a look in the default themes.xml and styles.xml but I don't see where to configure number 1 in particular...can someone let me know how this is done?
此外,一些我见过的解决方案,包括充气布局,然后设置该使用AlertDialog.Builder.setView()...如果我是用这种方式那么我该如何设计一个积极的意见,定制和消极的按钮?
Also, some of the solutions I've seen involve inflating a layout and then setting this using AlertDialog.Builder.setView()...if I was to customize using this way then how do I design the views for positive and negative buttons?
感谢
推荐答案
对不起,警告对话框是不是真的打算为主题的那样。他们基本上是你能做的最具体的东西 - 一个罐头外观标准的常见情况
Sorry, alert dialogs are not really intended to be themed like that. They are basically the most concrete thing you can do -- a canned appearance for standard common situations.
如果你想有一个自定义外观的对话框,你应该只是开始与Dialog类。
If you want to have a dialog with a customized appearance, you should just start with the Dialog class.
这篇关于安卓:AlertDialogs的简单的定制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!