title: scaling and rotating imageview
body: <p>I'm preparing somecompass activity. 
  I have my rose of winds .png and I want to scale it on activity start and rotate after orientation changed.</p>
  
  <p>The problem is that when i scale my image (onCreate only), after first (and only first) use of rotate method my view is resized one more time, and I have no idea why.</p>
  
  <p>Let me post you my rotate and scale methods. rose is my ImageView instance (ImageView rose)</p>
  
  <p>Please take a look and post any advices. Should I try different way to scale my ImageView ?</p>
  
  <p>Thx for any help !</p>
  
  <p>Rotate (looks like working fine)</p>
  
  <pre><code>public void rotateRose(float angle){
  
              angle = 360 - angle;
              Matrix matrix=new Matrix();
              rose.setScaleType(ScaleType.MATRIX);
              pivX = rose.getDrawable().getBounds().width()/2;
              pivY = rose.getDrawable().getBounds().height()/2;
              matrix.preRotate((float) angle, pivX, pivY);
              rose.setImageMatrix(matrix);
  }
  </code></pre>
  
  <p>Scale (found <a href="http://argillander.wordpress.com/2011/11/24/scale-image-into-imageview-then-resize-imageview-to-match-the-image/" rel="nofollow">source link</a>)</p>
  
  <pre><code>private void scaleImage(ImageView view, int boundBoxInDp)
      {
          // Get the ImageView and its bitmap
          Drawable drawing = view.getDrawable();
          Bitmap bitmap = ((BitmapDrawable)drawing).getBitmap();
  
          // Get current dimensions
          int width = bitmap.getWidth();
          int height = bitmap.getHeight();
  
          // Determine how much to scale: the dimension requiring less scaling is
          // closer to the its side. This way the image always stays inside your
          // bounding box AND either x/y axis touches it.
          float xScale = ((float) boundBoxInDp) / width;
          float yScale = ((float) boundBoxInDp) / height;
          float scale = (xScale &lt;= yScale) ? xScale : yScale;
  
          // Create a matrix for the scaling and add the scaling data
          Matrix matrix = new Matrix();
          matrix.postScale(scale, scale);
  
          // Create a new bitmap and convert it to a format understood by the ImageView
          Bitmap scaledBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
          BitmapDrawable result = new BitmapDrawable(scaledBitmap);
          width = scaledBitmap.getWidth();
          height = scaledBitmap.getHeight();
  
          // Apply the scaled bitmap
          view.setImageDrawable(result);
  
          // Now change ImageView's dimensions to match the scaled image
          RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) view.getLayoutParams();
          params.width = width;
          params.height = height;
          view.setLayoutParams(params);
  
          //pivX = width/2;
         // pivY = height/2;
      }
  </code></pre>