我正在使用以下代码来主题AlertDialogs。AlertDialog中顶部分隔符的ID
Resources resources = dialog.getContext().getResources();
int color = resources.getColor(R.color.green_theme); // your color here
int alertTitleId = resources.getIdentifier("alertTitle", "id", "android");
TextView alertTitle = (TextView) dialog.getWindow().getDecorView().findViewById(alertTitleId);
alertTitle.setTextColor(color); // change title text color
int titleDividerId = resources.getIdentifier("titleDivider", "id", "android");
View titleDivider = dialog.getWindow().getDecorView().findViewById(titleDividerId);
titleDivider.setBackgroundColor(color); // change divider color
它的效果很好,除了AlertDialog带有消息但没有标题的情况。看来只有在这种情况下才会显示第三个视图,该视图也需要设置其颜色。我只是不知道这个视图的id是什么。有人知道吗?
我在说的视图在下图中的白色矩形中突出显示。
我不想摆脱它,我想改变颜色,这样它的文本匹配。 – zholmes1 2014-10-10 06:15:14
AFAIK,这是你正在使用的主题的一部分。你必须调整主题。这是一个SO帖子:http://stackoverflow.com/questions/2422562/how-to-change-theme-for-alertdialog – 2014-10-10 06:18:28