title: Android. Obtaining image size from it's resource id
body: <p>This is a part of my Activity:</p>
  
  <pre><code>private ImageView mImageView;
  private int resource;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    resource = getIntent().getIntExtra("res", -1);
  
    Matrix initMatrix = new Matrix();
  
    mImageView = new ImageView(getApplicationContext());
    mImageView.setScaleType( ImageView.ScaleType.MATRIX );
    mImageView.setImageMatrix( initMatrix );
    mImageView.setBackgroundColor(0);
    mImageView.setImageResource(resource);
  }
  </code></pre>
  
  <p>I try to display an image within an ImageView using a matrix as scale type (I want to add multitouch later). But before user starts interaction i want the image to be centered and fit inside the ImageView.
  I already found answers concerning how to solve it but there is one problem for me:
  to make image centered using matrix I need to know its width and height. Is there any way of getting image size when all you have is <strong>int resource</strong> ?</p>