Dimezis / BlurView

Dynamic iOS-like blur of underlying Views for Android
Apache License 2.0
3.48k stars 331 forks source link

blurView在compose中无效 #207

Closed aacai closed 3 months ago

aacai commented 11 months ago

在jetpack compose官方的与View交互AndroidView中,模糊效果不生效

AndroidView(
    modifier = Modifier
        .fillMaxSize()
        .border(width = 5.dp, color = Color.Red),
    factory = { context ->
        LinearLayout(context).apply {
            orientation = LinearLayout.VERTICAL
            layoutParams = ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT
            )
            addView(ImageView(context).apply {
                setImageResource(R.drawable.ic_wallpaper)
                layoutParams = ViewGroup.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT
                )
            })

            addView(BlurView(context).apply {
                setupWith(viewGroup, getBlurAlgorithm(context))
                    .setFrameClearDrawable(
                        context.getDrawable(R.drawable.ic_wallpaper)
                    )
                    .setBlurEnabled(true)
                    .setBlurRadius(30f)
                setOverlayColor(android.graphics.Color.RED)
                layoutParams = ViewGroup.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT
                )

            })
        }
    })

但是在传统的View中使用却没问题,我在哪里出错了呢,还是程序的bug?