From 9905ef8f569c5ce27fefd3c2deddf6643f9df597 Mon Sep 17 00:00:00 2001 From: Tadas Luksa Date: Thu, 22 Feb 2018 16:34:30 +0100 Subject: [PATCH] Transparent fill property from 'g' was not overriding inner elements fill properties. Example (rect was painting Black color, although it has to be overriden by 'g' fill="none" and be transparent): --- library/src/main/java/com/pixplicity/sharp/Sharp.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/src/main/java/com/pixplicity/sharp/Sharp.java b/library/src/main/java/com/pixplicity/sharp/Sharp.java index 859b777..ea99900 100644 --- a/library/src/main/java/com/pixplicity/sharp/Sharp.java +++ b/library/src/main/java/com/pixplicity/sharp/Sharp.java @@ -1240,6 +1240,7 @@ public static class SvgHandler extends DefaultHandler { private Paint mFillPaint; private boolean mFillSet = false; + private int mFillColor; private Stack mFillPaintStack = new Stack<>(); private Stack mFillSetStack = new Stack<>(); @@ -1393,6 +1394,7 @@ private boolean doFill(Properties atts, RectF boundingBox) { } } else { if (mFillSet) { + mFillPaint.setColor(mFillColor); // If fill is set, inherit from parent // optimization: return false if transparent return mFillPaint.getColor() != Color.TRANSPARENT; @@ -1794,6 +1796,9 @@ public void startElement(String namespaceURI, String localName, String qName, At doStroke(props, null); mFillSet |= (props.getString("fill") != null); + if(mFillSet) { + mFillColor = mFillPaint.getColor(); + } mStrokeSet |= (props.getString("stroke") != null); SvgGroup group = new SvgGroup(id);