View view = Findviewbyid (R.ID.PHOTOSELECTBG_IV_RL11); Get layout Control Properties final Bitmap BMP = Bitmap.createbitmap (View.getwidth (), View.getheight (), Bitmap.Config.RGB_8888); View.draw (new Canvas (BMP)); SimpleDateFormat DateFormat = new SimpleDateFormat ("Yyyymmddhhmmss"); String time = Dateformat.format (new Date ()); File dir = new file (Gloableparams.img_file_path); if (!dir.exists ()) { dir.mkdirs (); } Final String Photourl = Gloableparams.img_file_path + Time + ". png";//Replace with your own picture save path final File File = new file (photourl); new Thread () {@Overridepublic void run () {try {Boolean bitmapok = Bmp.compress (compressformat.png, +, new FileOutputStream ( file), if (bitmapok) {myapp.photofile = File;myapp.photourl = Photourl;} catch (FileNotFoundException e) { E.printstacktrace ();}}}. Start ();
The core is View.draw ();
android--saving layouts as images