Bitmap size changes
<p>I have an ImageView containing an image. This image is rotated by button clicks, but sometimes it gets smaller or gets its original size. I have no idea what causes this.</p>

<pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" &gt;

    //tablelayout here

     &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true" 
        android:layout_centerVertical="true"
        android:orientation="vertical" &gt;
    &lt;ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:maxWidth="200dp" 
        android:maxHeight="200dp"
         /&gt; 
    &lt;/LinearLayout&gt;
&lt;/RelativeLayout&gt;
</code></pre>

<p>Inital settings:</p>

<pre><code> iv = (ImageView)findViewById(R.id.imageView1);
        int id = getResources().getIdentifier("landolt", "drawable", getPackageName());
        iv.setImageResource(id);

        myImg = BitmapFactory.decodeResource(getResources(), R.drawable.landolt);
        matrix = new Matrix();

        size = 200;

        randomize = new Random();
        random = randomize.nextInt(8) + 1;
        rotate = getAngle(random);  //function created by me
        matrix.postRotate(rotate);
        rotatedBitmap = Bitmap.createBitmap(myImg, 0, 0, myImg.getWidth(), myImg.getHeight(), matrix, true);
        iv.setImageBitmap(rotated);
</code></pre>

<p>So the image is rotated, no size change in code.</p>

<p>A rotation on button click:</p>

<pre><code>                btn1.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (rotate == -90)
                        {
                          //rotate back to original direction
                            old_rotate = -rotate;
                            matrix.postRotate(old_rotate);
                          //next rotation
                            random = randomize.nextInt(8) + 1;
                            rotate = getAngle(random);
                            matrix.postRotate(rotate);
                            rotatedBitmap = Bitmap.createBitmap(myImg, 0, 0, myImg.getWidth(), myImg.getHeight(), matrix, true);
                            iv.setLayoutParams(new LinearLayout.LayoutParams(size, size));
                            iv.setImageBitmap(rotated);
                        }
                    }
                    });
</code></pre>

<p>When I launch the activity, the image appears with its original size, sometimes smaller. When I click on a button the image gets smaller or gets as big as its original size.</p>

<p>What is going on?</p>
