Merge pull request #27 from NativeScript/image-rounding

Fix: Images have margin when added to Layout
This commit is contained in:
Rossen Hristov
2016-06-14 13:14:30 +03:00
committed by GitHub

View File

@@ -73,8 +73,8 @@ public class ImageView extends android.widget.ImageView {
if (measureWidth != 0 && measureHeight != 0 && (finiteWidth || finiteHeight)) { if (measureWidth != 0 && measureHeight != 0 && (finiteWidth || finiteHeight)) {
this.computeScaleFactor(width, height, finiteWidth, finiteHeight, measureWidth, measureHeight); this.computeScaleFactor(width, height, finiteWidth, finiteHeight, measureWidth, measureHeight);
int resultW = (int) Math.floor(measureWidth * this.scaleW); int resultW = (int) Math.round(measureWidth * this.scaleW);
int resultH = (int) Math.floor(measureHeight * this.scaleH); int resultH = (int) Math.round(measureHeight * this.scaleH);
measureWidth = finiteWidth ? Math.min(resultW, width) : resultW; measureWidth = finiteWidth ? Math.min(resultW, width) : resultW;
measureHeight = finiteHeight ? Math.min(resultH, height) : resultH; measureHeight = finiteHeight ? Math.min(resultH, height) : resultH;