Skip to content

Commit b5e5eb4

Browse files
authored
Merge pull request #655 from connyduck/master
handle padding correctly
2 parents 3aa8ebe + 7d14426 commit b5e5eb4

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

touchview/src/main/java/com/ortiz/touchview/TouchImageView.kt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -548,12 +548,8 @@ open class TouchImageView @JvmOverloads constructor(context: Context, attrs: Att
548548
savePreviousImageValues()
549549
}
550550

551-
// Image view width, height must consider padding
552-
val width = totalViewWidth - paddingLeft - paddingRight
553-
val height = totalViewHeight - paddingTop - paddingBottom
554-
555551
// Set view dimensions
556-
setMeasuredDimension(width, height)
552+
setMeasuredDimension(totalViewWidth, totalViewHeight)
557553
}
558554

559555
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
@@ -574,8 +570,8 @@ open class TouchImageView @JvmOverloads constructor(context: Context, attrs: Att
574570
// repeated computations, and making irreversible changes (e.g. making the View temporarily too
575571
// big or too small, thus making the current zoom fall outside of an automatically-changing
576572
// minZoom and maxZoom).
577-
viewWidth = w
578-
viewHeight = h
573+
viewWidth = w - paddingRight -paddingLeft
574+
viewHeight = h - paddingTop - paddingBottom
579575
fitImageToView()
580576
}
581577

0 commit comments

Comments
 (0)