How to use Android DialogFragment setStyle()

Viewed 17311

I'm trying to setStyle to my custom dialog that extends dialogFragment, constructor looks like:

MyCustomDialog() {
  super();
  setStyle(STYLE_NO_FRAME, 0);
}

and I still see the frame around my layout.

Does anyone have any ideas?

5 Answers

In my opinion, it is better to override theme getter

override fun getTheme(): Int {
    return R.style.BottomSheetDialogTheme
}

try adding this to the onCreate method in DialogFragment:

setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Material_Dialog_MinWidth);

If you want to set a custom theme for your a dialog you can do it this way...

AlertDialog.Builder(context, R.style.MyDialogTheme) ...
Related