当我启动我的应用程序时,它会启动一个 Activity
,它应该有透明的 header ,并且背景中当前显示的任何内容都应该是模糊的。
我能够获得透明度。但我无法弄清楚如何模糊背景。例如,如果我从主屏幕启动应用程序,那么主屏幕应该是可见的但模糊了。
我想使用 Framebuffer 来获取当前显示的数据,但如何将其转换为位图,以便在不保存图像和直接使用数据的情况下绘制图像。
我也知道我们可以通过按电源和音量按钮截屏。有谁知道 android 中的代码在哪里?我的应用程序将具有系统访问权限。
最佳答案
how to blur the background?
您可以使用支持库中提供的RenderScript
public class BlurBuilder {
private static final float BITMAP_SCALE = 0.4f;
private static final float BLUR_RADIUS = 7.5f;
public static Bitmap blur(Context context, Bitmap image) {
int width = Math.round(image.getWidth() * BITMAP_SCALE);
int height = Math.round(image.getHeight() * BITMAP_SCALE);
Bitmap inputBitmap = Bitmap.createScaledBitmap(image, width, height, false);
Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap);
RenderScript rs = RenderScript.create(context);
ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap);
Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap);
theIntrinsic.setRadius(BLUR_RADIUS);
theIntrinsic.setInput(tmpIn);
theIntrinsic.forEach(tmpOut);
tmpOut.copyTo(outputBitmap);
return outputBitmap;
}
}
参见 this link了解更多详情
或者您可以使用 Blurry
Does anyone has an idea where is the code in android to do that?
要截取您的应用程序屏幕,请参阅 this link
关于android - 如何使 Activity 背景透明和模糊背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32021619/