我想在警告对话框标题标题的风格或改变颜色分隔。 我搜索一下这个问题,我想很多人在搜索this.But我仍然没能找到合适的解决方案。 我想改变这个如下。
Answer 1:
实际上,你可以通过一个非常简单的黑客改变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();
}
}
Answer 2:
分频器颜色: -
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.dialog)
.setIcon(R.drawable.ic)
.setMessage(R.string.dialog_msg);
Dialog d = builder.show();
int dividerId = d.getContext().getResources().getIdentifier("android:id/titleDivider", null, null);
View divider = d.findViewById(dividerId);
divider.setBackgroundColor(getResources().getColor(R.color.my_color));
Answer 3:
由源来看,似乎这种颜色是固定的。 我会认为这是一个错误,应该设置样式恕我直言。
有一个简单的解决办法,但:使用setStyle(DialogFragment.STYLE_NO_TITLE, R.style.myStyle);
,并且其中第一项是你的标题写一个简单的线性布局。
Answer 4:
QustomDialogBuilder qustomDialogBuilder = new QustomDialogBuilder(context).
setTitle("Set IP Address").
setTitleColor("#FF00FF").
setDividerColor("#FF00FF").
setMessage("You are now entering the 10th dimension.").
qustomDialogBuilder.show();
文章来源: How to change alert dialog header divider color android