在Android中以编程方式获取Invisible Layout的屏幕截图

时间:2016-08-30 09:00:08

标签: android screenshot screen-capture

我想在我的应用程序中实现共享功能。我想一次共享多个产品,因为我必须截取所有布局的屏幕截图。

关于它的任何想法。

1 个答案:

答案 0 :(得分:0)

尝试THIs:

 Bitmap b = Bitmap.createBitmap(yourLyout.getWidth(), yourLyout.getHeight(), Bitmap.Config.ARGB_8888);

                 int weight,height;
                 weight =  yourLyout.getWidth();
                 height =  yourLyout.getHeight();
                 Bitmap cs = Bitmap.createBitmap(weight, height, Bitmap.Config.ARGB_8888);
                 Canvas c = new Canvas(cs);
          c.drawBitmap(b,0,0,null);                  
           yourLyout.draw(c); 

步骤1:

      //First we get the root of sdcard/or ExternalStorage and then create a folder named photoEmail in sdcard by using mkdirs() method.

          Random generator = new Random();
          int n = 10000;
          n = generator.nextInt(n);

         String root = Environment.getExternalStorageDirectory() + "/PhotoEmail";
                 File file = new File(root); 
                 file.mkdirs();
        //Name the image file in sdcard with images.png

         //File file1 = new File(root + "/" +"images"+n".png");
         //Now open the file and compress our bitmap image and make the file image file with png ow Open

        fos = new FileOutputStream(file1); 
        if (fos != null) {
        cs.compress(Bitmap.CompressFormat.PNG, 90, fos);
         fos.close();
         }

步骤2

 Intent picMessageIntent = new Intent(android.content.Intent.ACTION_SEND); 
 picMessageIntent.setType("message/rfc822");#sthash.zPwDJd6s.dpuf
 File downloadedPic = new File("/sdcard/PhotoEmail/images.png")                
 picMessageIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(downloadedPic));
  startActivityForResult(picMessageIntent, 1);

步骤3:

<div class="modal fade" id="confirm-delete<?= $employee->id ?>" tabindex="-1" role="dialog" aria-labelledby="deleteModal" aria-hidden="true">
      <div class="modal-dialog">