'React native set view backgroundColor opacity

I have a view that I would like to set the background opacity to 0.5 however I need the text component inside of the view to show completely (as if its opacity was 1)

<View
        style={{
          position: 'absolute',
          bottom: 0,
          left: 0,
          backgroundColor: 'white',
          opacity: 0.5,
          borderRadius: 5,
        }}>
        <Paragraph>folder</Paragraph>
      </View>


Solution 1:[1]

If you want the text folder to be less opaque, then you will have to apply styling directly to it, while keeping its parent's opacity as desired -

<View
  style={{
    position: 'absolute',
    bottom: 0,
    left: 0,
    backgroundColor: 'white',
    opacity: 0.5,
    borderRadius: 5,
  }}>
  <Paragraph>
    <span style={{ opacity: 1 }}>
      folder
    </span>
  </Paragraph>
</View>

You can also try setting the backgroundColor with an opacity attached directly to it -

backgroundColor: rgb(0, 0, 0, 0.5)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1