【发布时间】:2013-07-26 14:14:32
【问题描述】:
今天我在我的 Nexus 7 上设置了新的 Android JB 4.3 并尝试运行我的应用程序。
除了ImageViews 和ScaleType.MATRIX 的一件小事外,一切正常。
基本上我在我的应用程序中拥有一个ImageView 作为背景,并根据ViewPager 回调移动图像的焦点部分,更新我使用setImageMatix( Matrix matrix ) 提供给imageView 的Matrix。
问题似乎是我无法再更新矩阵了,我只需要实例化一个新矩阵并将其传递给ImageView。
我设法解决它,每次实例化一个新的Matrix,但与旧版本相比,它的内存似乎非常昂贵。
这是一个BUG吗? 有没有办法更新Matrix? (顺便说一句,我已经尝试过invalidate() ImageView ecc。)
不工作
private void updateMatrix( final int page, final double offset ) {
double pagePosition = page + offset;
Matrix matrix = imageView.getImageMatrix();
matrix.setScale( scale, scale );
matrix.postTranslate( - (float) ( pagePosition * pageWidth ) , 0 );
imageView.setImageMatrix( matrix );
imageView.invalidate();
}
工作中
private void updateMatrix( final int page, final double offset ) {
double pagePosition = page + offset;
Matrix matrix = new Matrix();
matrix.setScale( scale, scale );
matrix.postTranslate( - (float) ( pagePosition * pageWidth ) , 0 );
imageView.setImageMatrix( matrix );
imageView.invalidate();
}
编辑:
在第一种情况下,图像显示在 ImageView 的左上角,没有应用任何缩放或平移,就像矩阵恢复身份一样。
【问题讨论】:
-
那么第一种情况发生了什么?有什么症状?
-
在第一种情况下,图像显示在 imageView 的左上角,没有应用任何缩放或平移。好像矩阵被重置了一样。
标签: android android-imageview android-4.3-jelly-bean