简体   繁体   English

Android,如何模糊/玻璃/霜当前活动

[英]Android, how to blur/glass/frost current activity

Basically 基本上

In an activity, I have a ListView. 在一个活动中,我有一个ListView。 When I select an item, an transparent activity opens as a small box. 当我选择一个项目时,透明活动将作为一个小框打开。 When this box appears, you can still view the previous activities screen, 出现此框时,您仍然可以查看以前的活动屏幕,

What I am trying to figure out is how to blur the previous screen like the image linked here (Ignore the UI, just look at the blurred grass area). 我想弄清楚的是如何模糊前一个屏幕,就像这里链接的图像一样(忽略用户界面,只看模糊的草地区域)。

How is this possible? 这怎么可能?

Thank you for any advice. 谢谢你的任何建议。

For API < 14, you could use the flag WindowManager.LayoutParams.FLAG_BLUR_BEHIND , but it's been deprecated and built-in blurring is no longer supported on higher APIs 对于API <14,您可以使用标志WindowManager.LayoutParams.FLAG_BLUR_BEHIND ,但它已被弃用,更高版本的API不再支持内置模糊

However, you could do this with a regular view or overlay. 但是,您可以使用常规视图或叠加层执行此操作。 What you want to do is: 你想要做的是:

  • Create a Bitmap from your activity's overall layout ( see here for example ) 从活动的整体布局创建Bitmap例如,请参见此处
  • Blur that bitmap with whatever method you want( a few examples here ) 用你想要的任何方法模糊那个位图( 这里有一些例子
  • Add(or unhide) a View in your layout that covers everything. 在布局中添加(或取消隐藏)涵盖所有内容的View Set bkg to blurred Bitmap 将bkg设置为模糊的位图
  • Open your dialog/transparent activity 打开对话框/透明活动
  • When it closes, either remove the View , or setVisibility(GONE) if you'll be using it again. 关闭时,如果您要再次使用它,请删除ViewsetVisibility(GONE)

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

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