I want to toggle 90-degree rotation when an image is tapped:
@UiThread // Android Annotations
void loadImage(ImageSource uri) {
image.setMinimumScaleType(SCALE_TYPE_CENTER_CROP);
image.setMaxScale(8);
image.setImage(uri); // I've tried the ImageViewState variant
image.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (image.getRotation() < 1) {
image.setRotation(90);
} else {
image.setRotation(0);
}
}
});
}
Where the image
is defined in a fragment:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
It's working, but the 90-degree rotated image does not occupy the whole screen. It has white background at the top and bottom.
How do I fix this?