DialogFragment with clear background (not dimmed)

前端 未结 4 1350
小蘑菇
小蘑菇 2020-11-30 02:01

I\'m trying to get the background of a DialogFragment to be completely clear.

With setting the style item android:windowIsFloating to true

4条回答
  •  半阙折子戏
    2020-11-30 02:36

    You need to get a handle to your DialogFrament (sometime after .show is called), and do this in a Posted Runnable:

    DialogFragment dialog;
    
    ...
    
    WindowManagerLayoutParams wlp = dialog.Dialog.Window.Attributes;
    wlp.Flags &= ~WindowManagerFlags.DimBehind;
    dialog.Dialog.Window.Attributes = wlp;
    

    I got it from Aleks G's answer to Changing position of the Dialog on screen android .

提交回复
热议问题