如何获取scrollView中所有帧布局视图的整个位图

时间:2016-09-30 05:59:22

标签: android android-imageview android-bitmap

我正在尝试创建所有视图的位图。但我无法创建所有视图的位图,请帮我解决此问题。

1 个答案:

答案 0 :(得分:0)

公共位图叠加(FrameLayout frame_layout){

    frame_layout.setDrawingCacheEnabled(true);
    frame_layout.buildDrawingCache();
    return frame_layout.getDrawingCache();
}

public void saveImage(){
    Bitmap bitmap=overlay(print_layout);
    try{
        String path = Environment.getExternalStorageDirectory().toString()+ File.separator+"bitmap";
        File path_file=new File(path);
        path_file.mkdirs();
        OutputStream fOut = null;
        File file = new File(path+ File.separator+"print.png"); // the File to save to
        fOut = new FileOutputStream(file);
        bitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut); // saving the Bitmap to a file compressed as a JPEG with 85% compression rate
        fOut.flush();
        fOut.close();
        Log.d("sun","saved");
    }
    catch (Exception e){
        Log.d("sun",e.toString());
    }
}