在Android中缩放图像视图

问题描述 投票:0回答:1

我是Android的新手,正在尝试前一段时间在PAckt购买的Android应用程序开发食谱的食谱。配方使用自定义转场创建缩放动画引入了以下代码:

        if((float)finalBounds.width()/finalBounds.height() > (float)startBounds.width()/startBounds.height()){
            startScale = (float) startBounds.height() / finalBounds.height();
            float startWidth = startScale*finalBounds.width();
            float deltaWidth = (startWidth - startBounds.width())/2;
            startBounds.left -= deltaWidth;
            startBounds.right += deltaWidth;
        }else{
            startScale = (float) startBounds.width() / finalBounds.width();
            float startHeight = startScale * finalBounds.height();
            float deltaHeight = (startHeight - startBounds.height())/2;
            startBounds.top -= deltaHeight;
            startBounds.bottom += deltaHeight;
        }

startBounds和finalBounds是分别与图像缩略图和原始Image有关的android Rect!我的问题是为什么比例因子startScale是用这种方式计算的,为什么startBounds分别用deltaWith和deltaHeight进行了调整?

android image scaling
1个回答
0
投票

ZoomLayout

查看此库希望对您有所帮助

© www.soinside.com 2019 - 2024. All rights reserved.