Android,如何模糊/玻璃/霜当前活动 [英] Android, how to blur/glass/frost current activity

查看:20
本文介绍了Android,如何模糊/玻璃/霜当前活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上

在一个活动中,我有一个 ListView.当我选择一个项目时,一个透明的活动会作为一个小框打开.当此框出现时,您仍然可以查看之前的活动屏幕,

In an activity, I have a 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).

这怎么可能?

感谢您的建议.

推荐答案

For API

14,您可以使用标志 WindowManager.LayoutParams.FLAG_BLUR_BEHIND,但它已被弃用,更高的 API 不再支持内置模糊

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

但是,您可以使用常规视图或叠加来执行此操作.你想要做的是:

However, you could do this with a regular view or overlay. What you want to do is:

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

这篇关于Android,如何模糊/玻璃/霜当前活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆