title: Fit to Android Imageview Matrix Center of Screen
body: <p>Hello Im using a function for fit to screen on this topic <a href="https://stackoverflow.com/questions/6075363/android-image-view-matrix-scale-translate">Android image view matrix scale + translate</a></p>
  
  <pre><code>float imageWidth = imageDetail.getDrawable().getIntrinsicWidth();
      float imageHeight = imageDetail.getDrawable().getIntrinsicHeight();
      RectF drawableRect = new RectF(0, 0, imageWidth, imageHeight);
      RectF viewRect = new RectF(0, 0, imageDetail.getWidth(),
              imageDetail.getHeight());
      matrix.setRectToRect(drawableRect, viewRect, Matrix.ScaleToFit.CENTER);
      imageDetail.setImageMatrix(matrix);
      imageDetail.invalidate();
  </code></pre>
  
  <p>It works effectively but not the first time. When I start the application It doesnt work. Image doesnt show. When I m tap It works. What Im do wrong?  Thanks for any advice</p>