位图叠加层在Pie中无法正常工作

时间:2019-12-09 05:21:20

标签: android bitmap android-9.0-pie

以下功能在android 8之前都可以使用,但在pie上不起作用:

public static Bitmap overlay(Bitmap bmp1, Bitmap bmp2) {
Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
Canvas canvas = new Canvas(bmOverlay);
canvas.drawBitmap(bmp1, new Matrix(), null);
canvas.drawBitmap(bmp2, 0, 0, null);
return bmOverlay;
}

所需的输出进入Pie下方:函数的第一个参数是图片捕获的输出,第二个参数是标题视图的位图。

Desired output getting in below Pie

饼图输出:

enter image description here

查看位图的方式:

public static Bitmap viewtoBitmap(View view,int width,int hight){
        Bitmap bitmap=Bitmap.createBitmap(width,hight,Bitmap.Config.ARGB_8888);
        Canvas canvas=new Canvas(bitmap);
        view.draw(canvas);
        return bitmap;
    }

1 个答案:

答案 0 :(得分:0)

以下功能在Pie(9)和Q(10)设备中正常工作:

public static Bitmap mergeBitmap(Bitmap bmp1, Bitmap bmp2) {
        Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
        Canvas canvas = new Canvas(bmOverlay);
        canvas.drawBitmap(bmp1, new Matrix(), null);
        canvas.drawBitmap(bmp2, new Matrix(), null);
        return bmOverlay;
    }