我正在使用以下代碼來主題AlertDialogs。AlertDialog中頂部分隔符的ID
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
它的效果很好,除了AlertDialog帶有消息但沒有標題的情況。看來只有在這種情況下才會顯示第三個視圖,該視圖也需要設置其顏色。我只是不知道這個視圖的id是什麼。有人知道嗎?
我在說的視圖在下圖中的白色矩形中突出顯示。
我不想擺脫它,我想改變顏色,這樣它的文本匹配。 – zholmes1 2014-10-10 06:15:14
AFAIK,這是你正在使用的主題的一部分。你必須調整主題。這是一個SO帖子:http://stackoverflow.com/questions/2422562/how-to-change-theme-for-alertdialog – 2014-10-10 06:18:28