0

I am trying to create bitmap of all view.but I am not able to create bitmap of all view,please help me to resolve this problem.

PriyankaChauhan
  • 953
  • 11
  • 26

1 Answers1

0

public Bitmap overlay(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());
    }
}