gpt4 book ai didi

android - 如何更改警报对话框标题分隔线颜色android

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:57:16 27 4
gpt4 key购买 nike

我想在警报对话框中设置样式或更改标题标题的分隔线颜色。我搜索了这个问题,我想很多人都在搜索这个。但我仍然无法找到正确的解决方案。我想更改以下内容。 Blue header divider

最佳答案

实际上,您可以通过非常简单的 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com