From c0bfe22e0d17971e8a7826028ddfed3af4170120 Mon Sep 17 00:00:00 2001 From: Nizam Moidu Date: Wed, 24 Oct 2018 22:34:36 +0400 Subject: [PATCH] dont create bitmap with 0 height/width during early render. when specify background color in react-native even parent view height/width could become zero https://github.com/react-native-community/react-native-svg/issues/823 --- android/src/main/java/com/horcrux/svg/SvgView.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/horcrux/svg/SvgView.java b/android/src/main/java/com/horcrux/svg/SvgView.java index cdd753c5..f41719cd 100644 --- a/android/src/main/java/com/horcrux/svg/SvgView.java +++ b/android/src/main/java/com/horcrux/svg/SvgView.java @@ -88,7 +88,8 @@ public class SvgView extends ReactViewGroup implements ReactCompoundView, ReactC if (mBitmap == null) { mBitmap = drawOutput(); } - canvas.drawBitmap(mBitmap, 0, 0, null); + if (mBitmap != null) + canvas.drawBitmap(mBitmap, 0, 0, null); } @Override @@ -214,6 +215,9 @@ public class SvgView extends ReactViewGroup implements ReactCompoundView, ReactC height = (float) PropHelper.fromRelative(mbbHeight, parentHeight, 0, mScale, 12); setMeasuredDimension((int)Math.ceil(width), (int)Math.ceil(height)); } + if (width == 0 || height == 0) { + return null; + } Bitmap bitmap = Bitmap.createBitmap( (int) width, (int) height,