I'm using the following code to theme my AlertDialogs.
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
It works well, except for the case where I have an AlertDialog with a message but no title. It appears that there is a third View that is only displayed in this case, which also needs to have its color set. I just don't know what the id of this View is. Does anyone know it?
The View I'm talking about is highlighted in the white rectangle in the picture below.