由网友(剪掉长发忘掉人渣)分享简介:我正在开发小型机器人application.and我想的标题标题提示对话框风格或改变颜色分。我搜索一下这个问题,我想很多人寻找this.But我仍然没有能够找到合适的解决方案。我想改变这个如下。I am developing small android application.and I wanted to style...
我正在开发小型机器人application.and我想的标题标题提示对话框风格或改变颜色分。我搜索一下这个问题,我想很多人寻找this.But我仍然没有能够找到合适的解决方案。我想改变这个如下。
I am developing small android application.and I wanted to style or change divider color of header title in alert dialog. I search about this question and I think lot of people searching for this.But I am still not able to find out right solution. I want to change this following.
推荐答案
实际上,你可以通过一个非常简单的黑客更改AlertDialog标题颜色:
You can actually change color of AlertDialog title by a very simple hack:
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();
}
}
相关推荐
最新文章