android 高斯模糊
mBinding.viewTransition.viewTreeObserver.addOnGlobalLayoutListener(object :
ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() {
mBinding.viewTransition.viewTreeObserver.removeOnGlobalLayoutListener(this)
val localRect = Rect()
mBinding.viewTransition.getGlobalVisibleRect(localRect)
val source = BitmapFactory.decodeResource(resources,R.drawable.bg)
val rectBitmap = Bitmap.createBitmap( source,localRect.left,localRect.top,localRect.width(),localRect.height())
LogUtils.e("x:"+mBinding.viewTransition.x+"y:"+mBinding.viewTransition.y+"w:"+mBinding.viewTransition.width+"h:"+mBinding.viewTransition.height)
mBinding.img.setImageBitmap(rectBitmap)
Glide.with(InitApplication.appliations!!.applicationContext).load(rectBitmap)
.dontAnimate()
.apply(bitmapTransform( BlurTransformation(5)))
.into(object :
CustomTarget<Drawable>() {
override fun onLoadCleared(placeholder: Drawable?) {
}
override fun onResourceReady(
resource: Drawable,
transition: Transition<in Drawable>?,
) {
mBinding.t111.background = resource
}
})
}
})