In my application i want the image which is inside the linear layout.So for that i have used
view.setDrawingCacheEnabled(true); // this is coming as undefined
view.buildDrawingCache(); // this is coming as undefined
Bitmap cache = view.getDrawingCache(); //here am getting null
But whenever i debug the code i am getting null at " view.getDrawingCache()".
Code
public static void saveLayout(View view) {
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap cache = view.getDrawingCache();
try {
FileOutputStream fileOutputStream = new FileOutputStream(Environment.getExternalStorageDirectory() + "/ss/file.png");
cache.compress(Bitmap.CompressFormat.PNG, 100, fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
} catch (Exception e) {
// TODO: handle exception
} finally {
view.destroyDrawingCache();
}
}
Usage
saveLayout(ll) // here ll is my linear layout
Please lemme know where i went wrong