我是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进行了调整?
查看此库希望对您有所帮助