1LinearLayout content = findViewById(R.id.rlid);
2content.setDrawingCacheEnabled(true);
3Bitmap bitmap = content.getDrawingCache();
4File file,f;
5if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
6 {
7 file =new File(android.os.Environment.getExternalStorageDirectory(),"TTImages_cache");
8 if(!file.exists())
9 {
10 file.mkdirs();
11
12 }
13 f = new File(file.getAbsolutePath()+file.seperator+ "filename"+".png");
14 }
15 FileOutputStream ostream = new FileOutputStream(f);
16 bitmap.compress(CompressFormat.PNG, 10, ostream);
17 ostream.close();
18
19 }
20 catch (Exception e){
21 e.printStackTrace();
22}
23