将ScrollView的整个内容保存为位图并不如预期的那样正常

时间:2015-04-24 10:41:39

标签: android android-bitmap

它显示可见区域正常,但不可见区域为黑色背景,如下所示:

enter image description here

这是我保存视图的方式

public Bitmap getBitmapFromView(View view, int totalHeight, int totalWidth) {
        Bitmap returnedBitmap = Bitmap.createBitmap(totalWidth,totalHeight , Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(returnedBitmap);
        Drawable bgDrawable = view.getBackground();
        if (bgDrawable != null)
            bgDrawable.draw(canvas);
        else
            canvas.drawColor(Color.WHITE);
        view.draw(canvas);
        return returnedBitmap;
    }

0 个答案:

没有答案