1

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.

Original image

Rotated image

How do I fix this?

wiradikusuma
  • 1,930
  • 4
  • 28
  • 44
  • Will this code work for you? http://stackoverflow.com/a/20146058/1163224 – ProblemSlover Oct 24 '15 at 14:17
  • @ProblemSlover nope, my issue is with a 3rd party library, https://github.com/davemorrissey/subsampling-scale-image-view sorry I forgot to mention it – wiradikusuma Oct 25 '15 at 15:04
  • Anyway, Well you can create a subclass of the image view and to override method which is responsible for displaying an image and try to apply/ the code suggested above – ProblemSlover Oct 25 '15 at 15:22

1 Answers1

1

It's setOrientation(), not setRotation(). The latter method belongs to View.

wiradikusuma
  • 1,930
  • 4
  • 28
  • 44