Im using an image as basically a view and putting text inside of it, i tried to give opacity to the image but everytime i try the text gets opacity too I don't really know why it happens
<View style={{flex: 1}}>
<View style={{height: 180,}}>
<Image source={{uri : this.state.fullURLImage}} style={{flex: 1,width: window.width,justifyContent:'center',alignItems:'center',opacity: 0.7}}>
<Text style={{textAlign: 'center',fontWeight: 'bold',color:'white',fontSize:16,}}>{this.state.title}</Text>
<Text style={{color:'white',fontSize:14,}}>{'\n'}July {this._try(this.state.day)} | {this.state.time_start} - {this.state.time_end}</Text>
</Image>
</View>
<View style={{flexGrow: 1, backgroundColor: 'white',}}>
<Text style={{textAlign:'center',color:'#1B3D6C',fontWeight:'bold',margin:10,marginTop: 40}}>{this.state.author}</Text>
<Text style={{margin:10,textAlign: (Platform.OS === 'ios') ? 'justify' : 'left'}}>{this.state.text}</Text>
</View>
<Image
source={{uri : this.state.fullURLAuthor}}
style={{
position: 'absolute',
top: 180 - 64 / 2,
height: 64,
width: 64,
left: (Dimensions.get('window').width - 64) / 2,
borderRadius: 32,
}}
/>
</View>
You need to put Text outside of image tag and give them position
OR
Also give opacity using like {backgroundColor: 'rgba(0,0,0,0.5)'}}
You can just use <ImageBackground>
instead of <Image>
and apply opacity and color as mentioned below.
<ImageBackground
style={{flex: 1,height: 110,resizeMode: 'cover',}}
source={imageSoure}
borderRadius={5}
resizeMode='cover'
imageStyle={{ opacity: 0.3,backgroundColor: 'YourFavouredColor'}}
>
<Text>
{someText}
</Text>
<Text>
{someOtherText}
</Text>
</ImageBackground>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With