📅  最后修改于: 2022-03-11 14:52:08.582000             🧑  作者: Mango
LinearLayout content = findViewById(R.id.rlid);
content.setDrawingCacheEnabled(true);
Bitmap bitmap = content.getDrawingCache();
File file,f;
if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
{
file =new File(android.os.Environment.getExternalStorageDirectory(),"TTImages_cache");
if(!file.exists())
{
file.mkdirs();
}
f = new File(file.getAbsolutePath()+file.seperator+ "filename"+".png");
}
FileOutputStream ostream = new FileOutputStream(f);
bitmap.compress(CompressFormat.PNG, 10, ostream);
ostream.close();
}
catch (Exception e){
e.printStackTrace();
}