DialogFragment 全透明设置

90 阅读1分钟

DialogFragment全透明设置

如题,只需要在启动 DialogFragment 的地方调用以下代码即可

val attributes = dialog?.window?.attributes
attributes?.apply {
    width = ViewGroup.LayoutParams.MATCH_PARENT
    height = ViewGroup.LayoutParams.MATCH_PARENT
    gravity = Gravity.TOP
    dimAmount = 0f // 去除半透明遮罩
    flags = flags or WindowManager.LayoutParams.FLAG_DIM_BEHIND // 去除半透明遮罩
}