I'm rotating a zoom-able ImageView upon button click as follows:
Float cur_angle = imageView.getRotation();
imageView.setPivotX(imageView.getWidth() / 2);
imageView.setPivotY(imageView.getHeight() / 2);
imageView.animate().rotation(cur_angle + add_angle).setDuration(delay);
imageView.invalidate();
XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivityFragment"
android:id="@+id/rel_layout" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/map_view"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:src="@drawable/store_map"
android:scaleType="centerCrop"
android:layout_alignParentBottom="false" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rotate"
android:id="@+id/rotate_right"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
After a 90 degree rotation (add_angle = 90), in case I zoom-in so the image is large enough in the Y axis, the image gets cut at the top and bottom. It seems like the imageView vertical dimension is kept equal or smaller than the original imageView width, which was limited to the width of the RelativeLayout it resides in (which is limited to the display size).
Why doesn't it "match parent" automatically after rotation and how do I force it to?
Just for the sake of experiemnt I've tried rotation without animation but it makes no difference.
Thanks