gpt4 book ai didi

java - 为 1.5 开发的应用程序不能在 2.2 android 上运行

转载 作者:行者123 更新时间:2023-11-30 11:54:45 26 4
gpt4 key购买 nike

我从在线教程中得到了查看大图的代码。它适用于 1.5,但是当我使用 Android 2.2 库时它不起作用。 (我的应用程序使用 2.2)我已经搜索了这个问题的答案,但没有运气。我怀疑这可能与可绘制文件夹有关?图像加载,但无法执行缩放或移动图像等操作。

 private void updateDisplay(){
calculateSourceRect(current_centerX, current_centerY, current_scale);
//where sourceRect = new RectF(); and destinationRect = new RectF();
matrix.setRectToRect(sourceRect, destinationRect, Matrix.ScaleToFit.FILL);
androidBigImageView.setImageMatrix(matrix);
}

private void calculateSourceRect(int centerX, int centerY, float scale){
int xSubValue;
int ySubValue;

if(destinationRect.bottom >= destinationRect.right){
ySubValue = (int)((imageSizeY/2) / scale);
xSubValue = ySubValue;

xSubValue = (int) (xSubValue * ((float)androidBigImageView.getWidth() / (float)androidBigImageView.getHeight()));
}
else{
xSubValue = (int)((imageSizeX/2) / scale);
ySubValue = xSubValue;

ySubValue = (int) (ySubValue * ((float)androidBigImageView.getHeight() / (float)androidBigImageView.getWidth()));
}

if(centerX - xSubValue < 0) {
animation.stopProcess();
centerX = xSubValue;
}
if(centerY - ySubValue < 0) {
animation.stopProcess();
centerY = ySubValue;
}
if(centerX + xSubValue >= imageSizeX) {
animation.stopProcess();
centerX = imageSizeX - xSubValue - 1;
}
if(centerY + ySubValue >= imageSizeY) {
animation.stopProcess();
centerY = imageSizeY - ySubValue - 1;
}

current_centerX = centerX;
current_centerY = centerY;

sourceRect.set(centerX - xSubValue, centerY - ySubValue, centerX + xSubValue, centerY + ySubValue);
}

最佳答案

试试 androidBigImageView.setScaleType(ScaleType.MATRIX);

关于java - 为 1.5 开发的应用程序不能在 2.2 android 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5439618/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com