diff --git a/library/src/main/java/com/zoonref/viewbehavior/SimpleViewBehavior.java b/library/src/main/java/com/zoonref/viewbehavior/SimpleViewBehavior.java index b14262c..e2462e5 100644 --- a/library/src/main/java/com/zoonref/viewbehavior/SimpleViewBehavior.java +++ b/library/src/main/java/com/zoonref/viewbehavior/SimpleViewBehavior.java @@ -108,15 +108,19 @@ void updateViewWithPercent(View child, float percent) { float newX = targetX == UNSPECIFIED_INT ? 0 : (targetX - mStartX) * percent; float newY = targetY == UNSPECIFIED_INT ? 0 : (targetY - mStartY) * percent; - // set scale - if (targetWidth != UNSPECIFIED_INT || targetHeight != UNSPECIFIED_INT) { + // set width scale + if (targetWidth != UNSPECIFIED_INT) { float newWidth = mStartWidth + ((targetWidth - mStartWidth) * percent); - float newHeight = mStartHeight + ((targetHeight - mStartHeight) * percent); - child.setScaleX(newWidth / mStartWidth); - child.setScaleY(newHeight / mStartHeight); // make up position for scale change newX -= (mStartWidth - newWidth) / 2; + } + + // set height scale + if (targetHeight != UNSPECIFIED_INT) { + float newHeight = mStartHeight + ((targetHeight - mStartHeight) * percent); + child.setScaleY(newHeight / mStartHeight); + // make up position for scale change newY -= (mStartHeight - newHeight) / 2; }