Java 为1.5开发的应用程序未在2.2 android上运行

Java 为1.5开发的应用程序未在2.2 android上运行,java,android,Java,Android,我从在线教程中获得了查看大图像的代码。 它在1.5中运行良好,但是当我使用Android2.2库时,它不起作用。(我的应用程序使用2.2) 我一直在寻找这个问题的答案,但运气不好。我怀疑这可能与drawable文件夹有关? 图像加载,但无法执行缩放或移动图像等操作 private void updateDisplay(){ calculateSourceRect(current_centerX, current_centerY, current_scale); //where

我从在线教程中获得了查看大图像的代码。 它在1.5中运行良好,但是当我使用Android2.2库时,它不起作用。(我的应用程序使用2.2) 我一直在寻找这个问题的答案,但运气不好。我怀疑这可能与drawable文件夹有关? 图像加载,但无法执行缩放或移动图像等操作

 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);
}
private void updateDisplay(){
计算资源竖立(当前中心X、当前中心Y、当前比例);
//其中sourceRect=new RectF();destinationRect=new RectF();
setRectToRect(sourceRect、destinationRect、matrix.ScaleToFit.FILL);
androidBigImageView.setImageMatrix(矩阵);
}
专用空心计算资源竖立(整数中心X、整数中心Y、浮动比例){
int-xSubValue;
int-ySubValue;
if(destinationRect.bottom>=destinationRect.right){
ySubValue=(int)((imageSizeY/2)/比例);
xSubValue=ySubValue;
xSubValue=(int)(xSubValue*((float)androidBigImageView.getWidth()/(float)androidBigImageView.getHeight());
}
否则{
xSubValue=(int)((imageSizeX/2)/比例);
ySubValue=xSubValue;
ySubValue=(int)(ySubValue*((float)androidBigImageView.getHeight()/(float)androidBigImageView.getWidth());
}
如果(centerX-xSubValue<0){
animation.stopProcess();
centerX=xSubValue;
}
if(centerY-ySubValue<0){
animation.stopProcess();
centerY=ySubValue;
}
如果(centerX+xSubValue>=imageSizeX){
animation.stopProcess();
centerX=imageSizeX-xSubValue-1;
}
如果(centerY+ySubValue>=imageSizeY){
animation.stopProcess();
centerY=imageSizeY-ySubValue-1;
}
当前_centerX=centerX;
当前_centerY=centerY;
sourceRect.set(centerX-xSubValue、centerY-ySubValue、centerX+xSubValue、centerY+ySubValue);
}

try
androidBigImageView.setScaleType(ScaleType.MATRIX)

尝试
androidBigImageView.setScaleType(ScaleType.MATRIX)谢谢你,艾丹克!工作得很有魅力!没问题!我回答了;)您现在应该通过单击答案旁边的“勾选”标记来接受答案。