I\'m building a custom DialogFragment. The dialog layout is set to my_dialog.xml, but how can I modify the color around the dialog (the transparent
I wanted a transparent background for my DialogFragment, and, in code, this works fine:
@Override
public void onStart() {
super.onStart();
Window window = getDialog().getWindow();
window.setBackgroundDrawableResource(android.R.color.transparent);
}
Of course, you can specify any color or Drawable using setBackgroundDrawable() or setBackgroundDrawableResource().
This works at least in onStart(), but not in onCreate(), and not necessarily in onCreateView(), it seems.
That said, in most cases it's probably cleaner to do this in XML, using styles, along these lines: