我想在警报对话框中设置样式或更改标题标题的分隔线颜色。我搜索了这个问题,我想很多人都在搜索这个。但我仍然无法找到正确的解决方案。我想更改以下内容。
最佳答案
实际上,您可以通过非常简单的 hack 更改 AlertDialog 标题的颜色:
public static void brandAlertDialog(AlertDialog dialog) {
try {
Resources resources = dialog.getContext().getResources();
int color = resources.getColor(...); // 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
} catch (Exception ex) {
ex.printStackTrace();
}
}
关于android - 如何更改警报对话框标题分隔线颜色android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15271500/