简体   繁体   English

如何模糊框架布局上新增视图的背景?Android

[英]How to blur the background of new added view on frame layout?Android

I am searching for it from very long time. 我很长时间都在寻找它。 I want to blur the background of the new added view to the frame layout. 我想模糊框架布局的新添加视图的背景。 The new added view is a linear layout which opens as a pop up. 新添加的视图是一个线性布局,以弹出方式打开。 Now how can I blur that frame layout. 现在我该如何模糊那个框架布局。

I have gone through all the posts regarding blurring the background but i did not find that useful for my problem Because they all suggest to create a bitmap and set it blur on the bitmap. 我已经浏览了关于模糊背景的所有帖子,但我没有发现对我的问题有用因为他们都建议创建一个位图并在位图上设置它模糊。 I simply want to blur the complete view behind the pop up 我只是想模糊弹出窗口后面的完整视图

Use this library to blur the background of popup https://github.com/faradaj/BlurBehind 使用此库来模糊弹出窗口https://github.com/faradaj/BlurBehind的背景

On BlurredActivity show the popup and finish the activity when pop dismiss. 在BlurredActivity上显示弹出窗口并在弹出关闭时完成活动。

You can use Renderscript Intrinsics, which are a set of built-in functions that require very little code to use, but are optimized for high-performance. 您可以使用Renderscript Intrinsics,它是一组内置函数,只需要很少的代码即可使用,但针对高性能进行了优化。

Once you have the blurring, the rest of the process is fairly straight forward. 一旦你模糊了,剩下的过程就相当简单了。 When you plan to leave an activity, create a bitmap of the current view and write it to disk. 当您计划保留活动时,请创建当前视图的位图并将其写入磁盘。 When you start your new activity (which should have a transparent background), you override the transition (otherwise you'll get the default zoom), and set the background to the blurred image you saved earlier. 当您开始新活动(应具有透明背景)时,您将覆盖转场(否则您将获得默认缩放),并将背景设置为您之前保存的模糊图像。 Add a fade in for the alpha and you get a nice little effect! 添加淡入淡出alpha并获得一个不错的小效果!

模糊视图

If you'd like to see how this looks in a sample project, you can find it on Github here . 如果你想看到了它在一个样本项目,你可以找到它在Github 这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM