DialogFragment views are ignored, the view behind the dialog is blurred and bleeds through
seth-gravy opened this issue · 1 comments
seth-gravy commented
I opened up a DialogFragment
and tried to blur a portion of it. Instead of seeing that portion blurred, I instead see through to a blurred version of what is behind the dialog.
I fixed it with a hack (note that all code is Kotlin):
class RealtimeBlurViewForDialogs(
context: Context?,
attrs: AttributeSet? = null,
private val decorView: View?
): RealtimeBlurView(context, attrs) {
override fun getActivityDecorView(): View = decorView ?: super.getActivityDecorView()
}
Usage inside my DialogFragment:
val blurView = RealtimeBlurViewForDialogs(context, null, dialog.window?.decorView).apply {
id = View.generateViewId()
setBlurRadius(50f)
setOverlayColor(Color.TRANSPARENT)
}
// add blurView where you want in your View hierarchy
I think the underlying issue is that when we detect and set mDifferentRoot
, we should use the new root as the DecorView instead of the initial root. By using the DecorView
of the dialog instead of the parent Activity
, which my hack does, the problem is resolved.
TianDehua commented
thanks, this resolve my problem, that Dialog blur effects always change!