React-native-vector-icons: How to fill with color transparent place in icon

Created on 25 Oct 2017  路  12Comments  路  Source: oblador/react-native-vector-icons

For example, I have bookmark check icon, and needs transparent check mark fill with color
Image
I tried in this way, but looks so

<View style={{ backgroundColor: 'white', height: 35, width: 35}}>
    <MaterialIcons
       name  = 'bookmark-check'
       size  = {30}
       color = {'blue'}
    />
</View>

Image

Most helpful comment

did anyone got the solution for the above issue..please let me know..i am facing the same

All 12 comments

I have problems with this too! I'm using "logo-youtube" from Ionicons and I want the middle play triangle to be white while the surrounding part is red, however if I add a white backgroundColor there will be a white box around the icon, and changing the padding to 0 does nothing at all.

Also having this issue with circle icons such as play-circle. Tried to add border radius and it doesn't seem to work (on iOS, using props, style, Text or View wrapper, or Icon.Button). So yeah, there's box behind the icon that would be nice to figure out how to not show.

Don't think this is possible with the current implementation I'm afraid :-/

did anyone got the solution for the above issue..please let me know..i am facing the same

Also having this issue

I'm also looking for a solution.

I also encountered this issue using NativeBase v2.8.0 which has react-native-vector-icons as dependency.

@oblador Is there any plans to change that? Or will it be "as is"? I think an ability to fill color is must have feature. Now it's not possible to do in any way (at least I couldn't find) neither with this repo, nor with React Native component (like imaginable overlay or whatever).

I also having this problem. Maybe adding a view behind the icon can fix the problem temporary.

I found a somewhat hacky work-around for this issue. I'm importing icons from NativeBase so the component is slightly different, but in @dennisbejencev-an's original example to achieve the desired result you can do something like this:

<View>
  <Icon
    type="MaterialCommunityIcons"
    name="bookmark"
    style={{
      color: "white",
      fontSize: 100
    }}
  />
  <Icon
    type="MaterialCommunityIcons"
    name="bookmark-check"
    style={{
      color: "blue",
      fontSize: 100,
      top: 0,
      left: 0,
      position: "absolute"
    }}
  />
</View>

res

Setting the second Icon to the absolute position 0,0 will overlay it onto the first. Since this example has a filled icon and a checked icon the overlay is perfect. It isn't a general solution since you need two similar icons, but it works in many cases. In situations where the overlay of the two icons doesn't quite line up from you can make one of the icons slightly larger than the other and fiddle around with the positioning to get to something acceptable.

Hope this helps!

I also having this problem. Maybe adding a view behind the icon can fix the problem temporary.

Good idea. I will use the solution before author fix the bug, but maybe is a feature. XD

name = 'bookmark-check'
size = {30}
color = {'blue'}
/>

try this out ... give borderRadius: 25 or until hide it. Note: no need for width and height if u already write size={30}

Hope this helps!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jakewtaylor picture jakewtaylor  路  4Comments

toddmetheny picture toddmetheny  路  4Comments

alihesari picture alihesari  路  3Comments

peacechen picture peacechen  路  3Comments

mahdidavoodi7 picture mahdidavoodi7  路  3Comments