开发者

Application developed for 1.5 is not running on 2.2 android

Ive got the code for viewing big images from the online tutorial. It works fine with 1.5, however when I use Android 2.2 library it does not work. (My application uses 2.2) I have searched for the answers for this problem, but no luck. I suspect it can be something to do with drawable folder? Images load, but actions like zooming or moving image can not be done.

 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.ge开发者_如何转开发tHeight() / (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);
}


try androidBigImageView.setScaleType(ScaleType.MATRIX);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜