DialogFragment with clear background (not dimmed)

前端 未结 4 1347
小蘑菇
小蘑菇 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:32

    What works for me is to adjust the WinowManager.LayoutParams in onStart() of the DialogFragment:

    @Override public void onStart() {
        super.onStart();
    
        Window window = getDialog().getWindow();
        WindowManager.LayoutParams windowParams = window.getAttributes();
        windowParams.dimAmount = 0.90f;
        windowParams.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND;
        window.setAttributes(windowParams);
    }
    

提交回复
热议问题