矩阵翻译不正确

时间:2015-04-25 06:06:46

标签: android android-imageview matrix-transform

我现在正在使用ImageView和Matrix翻译。我尝试使用此代码翻译图像。

ImageView view = (ImageView) findViewById(R.id.imageView);
view.setScaleType(ImageView.ScaleType.MATRIX);

Matrix matrix = new Matrix();
matrix.postTranslate(0, 0);

view.setImageMatrix(matrix);

使用上面的代码,ImageView会在屏幕左上角显示左上角的图像(编号1)。然后我尝试将翻译值更改为matrix.postTranslate(-1280, -960);我期望的(数字3)是屏幕外的图像显示,因为图像尺寸为1280 x 960像素。但结果如下图所示(数字2)。

enter image description here

*黑色矩形是我设备屏幕上显示的内容。

我的问题是为什么只将图像转换为-1280,-960才将图像移动到中心?翻译单元不是像素吗?或者我在这里弄错了? 我的设备是Samsung Note 3 Neo,分辨率为720 x 1280像素。

0 个答案:

没有答案
相关问题