question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

On the Android platform, when using currentColor as the fill value, the opacity property is ignored.

See original GitHub issue

Unexpected behavior

On the Android platform, when using currentColor as the fill value, the opacity property is ignored. The iOS platform has no such problems

Simulator Screen Shot - iPhone 11 - 2020-04-14 at 14 02 29 Screenshot_1586844684

Environment info

 "react-native-svg": "^12.1.0",

Steps To Reproduce


 let xml = `<?xml version="1.0" encoding="utf-8"?>
  <svg version="1.1" id="e98f3141-fbb2-4194-a12f-8ac40d4ee285"
     xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 200 200"
     style="enable-background:new 0 0 200 200;" xml:space="preserve">
  <title>listen_now_inactive</title>
  <path fill="currentColor" d="M85.3,24.3h-59c-6.2,0-11.3,5-11.3,11.1c0,0.1,0,0.1,0,0.2v8.7h92.8l-8.3-12.5C96.2,27.2,90.9,24.4,85.3,24.3z"
    />
  <g>
    <path fill="currentColor" opacity="0.1" d="M173.7,44.3H15v119c0,0.1,0,0.1,0,0.2c0,6.2,5.1,11.2,11.3,11.1h147.4c0.1,0,0.1,0,0.2,0
      c6.2,0,11.2-5.1,11.1-11.3V55.6c0-0.1,0-0.1,0-0.2C185,49.3,179.9,44.3,173.7,44.3z M127.6,114.1l-47.3,20.8
      c-0.6,0.3-1.3,0.4-2,0.4c-2.8,0-5.1-2.3-5.1-5.1V88.7c0-0.7,0.1-1.4,0.4-2c1.1-2.6,4.1-3.7,6.7-2.6l47.3,20.8
      c1.3,0.5,2.2,1.5,2.8,2.7C131.5,110.1,130.2,113,127.6,114.1z"/>
    <path fill="currentColor" d="M127.6,104.8L80.3,84c-2.6-1.1-5.5,0-6.7,2.6c-0.3,0.6-0.4,1.3-0.4,2v41.5c0,2.8,2.3,5.1,5.1,5.1
      c0.7,0,1.4-0.1,2-0.4l47.3-20.8c2.6-1.1,3.8-4,2.8-6.6C129.9,106.2,128.9,105.3,127.6,104.8z"/>
  </g>
  </svg>`;

 <SvgCss xml={xml} width="100" height="100" color="red" />

Describe what you expected to happen: The renderings of iOS and Android platforms should look the same

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:9
  • Comments:12

github_iconTop GitHub Comments

3reactions
psnfrenchcommented, Oct 27, 2020

I faced the same issue too, but a workaround that worked for me was to change the opacity to the style prop ie. change: opacity="0.4" to: style="opacity:0.4"

2reactions
stale[bot]commented, Jun 13, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a “discussion” and I will leave this open.

Read more comments on GitHub >

github_iconTop Results From Across the Web

On the Android platform, when using currentColor as the fill ...
Unexpected behavior On the Android platform, when using currentColor as the fill value, the opacity property is ignored.
Read more >
VectorDrawable | Android Developers
If this property is animated, any value set by the animation will override the original value. No path fill is drawn if this...
Read more >
currentColor with opacity - Stack Overflow
i.e. inherit currentColor in #inner2 and set it's opacity to 0.25 . Searching for a pure css solution please. impossible... you can use...
Read more >
fill-opacity - SVG: Scalable Vector Graphics - MDN Web Docs
The fill-opacity attribute is a presentation attribute defining the opacity of the paint server (color, gradient, pattern, etc.)
Read more >
5 Gotchas You're Gonna Face Getting Inline SVG Into ...
If your source SVG was exported with black fills only (no ... Well, the long supported CSS value currentColor , specifies that color...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found