2015-10-24 39 views
1

欲切换90度旋转时的图像被点击:子采样尺度图像视图setRotation不占据整个屏幕

@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); 
      } 
     } 
    }); 
} 

image中的片段被定义:

<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> 

它的工作,但90度旋转的图像不占用整个屏幕。它有顶部和底部的白色背景。

Original image

Rotated image

我该如何解决这个问题?

+0

此代码是否适合您? http://stackoverflow.com/a/20146058/1163224 – ProblemSlover

+0

@ProblemSlover nope,我的问题是与第三方库,https://github.com/davemorrissey/subsampling-scale-image-view抱歉,我忘了提及它 – wiradikusuma

+0

无论如何,那么你可以创建图像视图的子类,并覆盖负责显示图像的方法,并尝试应用/上面建议的代码 – ProblemSlover

回答

1

这是setOrientation()而不是setRotation()。后一种方法属于View