恭维不会使女人飘然,却往往使男人丧志。——王尔德
安卓实现一个毛玻璃效果可以使用Blurry
https://github.com/wasabeef/Blurry
代码:
| 12
 3
 4
 5
 6
 7
 
 | Blurry.with(context).radius(25).sampling(2).onto(rootView)
 
 
 Blurry.with(context).capture(view).into(imageView)
 
 Blurry.with(context).from(bitmap).into(imageView)
 
 | 
Blur Options 模糊选项
- Radius 半径
- Down Sampling 下采样
- Color Filter 彩色滤光片
- Asynchronous Support 异步支持
- Animation (Overlay Only)
 动画(仅限叠加)
| 12
 3
 4
 5
 6
 7
 
 | Blurry.with(context).radius(10)
 .sampling(8)
 .color(Color.argb(66, 255, 255, 0))
 .async()
 .animate(500)
 .onto(rootView);
 
 | 
Get a bitmap directly 直接获取位图
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 
 | val bitmap = Blurry.with(this)
 .radius(10)
 .sampling(8)
 .capture(findViewById(R.id.right_bottom)).get()imageView.setImageDrawable(BitmapDrawable(resources, bitmap))
 
 
 Blurry.with(this)
 .radius(25)
 .sampling(4)
 .color(Color.argb(66, 255, 255, 0))
 .capture(findViewById(R.id.left_bottom))
 .getAsync {    imageView.setImageDrawable(BitmapDrawable(resources, it))  }
 
 |