我正在使用ImageView来展示图像。有一个“图像 - ”按钮,当我点击它时,ImageView将使用矩阵来缩放图像。问题是,图像最终太小而看不到。如何缩放不应小于指定大小的图像
你可以看到我的例子。
原始图像:
你可以看到沙发形象是如此之小,现在很难看到:
点击按钮 “Image--” 12次后。
我的 “main.xml中” 内容为:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/root" xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- buttons -->
</LinearLayout>
<ImageView android:id="@+id/imageView" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:adjustViewBounds="true" android:background="#336699"
android:scaleType="matrix"/>
</LinearLayout>
我的Java代码:
this.btnImageZoomOut.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Matrix matrix = new Matrix(imageView.getImageMatrix());
matrix.postScale(0.8f, 0.8f);
imageView.setImageMatrix(matrix);
imageInfo();
}
});
我的问题是:如何让沙发的图像会更小指定的大小?例如原尺寸的1/5?
UPDATE
如果我能得到缩放沙发图像的大小,它会很容易检查,如果图像太小。但我尝试了很多,仍然没有得到它,这就是为什么我问这个问题。我想念什么?
我需要矩阵类型,因为我也必须对图像进行旋转。但如果这太难了,我只会旋转90/180/270,我仍然可以使用您的解决方案。现在让我试试。 – Freewind
是的,您不必使用布局参数进行缩放,但您可以通过这种方式获取大小以进行检查。 (您不需要设置刻度类型) – Edison
我仍然可以使用矩阵进行缩放吗?并使用布局参数获取大小? – Freewind