title: Is it possible to convert a Layout to Image with the same size regardless of the phone's density?
body: <p>I have an application that I need to convert a layout into an image but the problem is that the image will have a different resolution depending on the phone's density.</p>
  
  <p>If I use the app on Phone A, the resolution will be 480x350, but on Phone B, the image's resolution will be 400x280. My question is: Is it possible to convert this layout into an image, but with the same resolution for every phone regardless on it's density?</p>
  
  <p>My code:</p>
  
  <pre><code>    private void salva() {
      if(myDir.exists()==false) {
          myDir.mkdirs();
      }
      RL = (RelativeLayout) findViewById(R.id.CardsLay);
      RL.setDrawingCacheEnabled(true);
      img = RL.getDrawingCache();
      Canvas canvas = new Canvas(img);
      try {
          FileOutputStream out = new FileOutputStream(file);
          canvas.drawBitmap(img, 0, 0, null);
          img.compress(CompressFormat.JPEG, 80, out);
          out.flush();
          out.close();
          RL.setDrawingCacheEnabled(false);
          Toast.makeText(getApplicationContext(), "Image saved on phone", Toast.LENGTH_LONG).show();
      }
      catch (Exception e) {
          e.printStackTrace();
          Toast.makeText(getApplicationContext(), "Ops", Toast.LENGTH_SHORT).show();
      }
  }
  </code></pre>