I have a main activity where users can change (via preferences) the background colour to their favourite colour. My problem is that I can not change the background colour o
The suggested solution
d.getWindow().setBackgroundDrawableResource(R.drawable.menubackground);
Do not work well (tested in 6.0) as it changes the dialog shadow
Here Is my solution:
public static void changeDialogBackground(final Dialog dialog,final int resId) {
dialog.getWindow().getDecorView().setBackgroundResource(resId);
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(final DialogInterface dialog) {
Window window = ((AlertDialog)dialog).getWindow();
window.getDecorView().setBackgroundResource(resId);
}
});
}