I have been trying to develop screen mentioned below:
For that I have created below component:
import React, {Component} from 'react';
import {View, Text, StyleSheet, ImageBackground, Image} from 'react-native';
import Balance from './Balance.js'
class AccountHeader extends React.Component{
render(){
return(
<ImageBackground
source={require('../images/lawrance.jpg')}
style={styles.container}>
<View style={styles.overlay}></View>
<Text style = {[styles.textStyle, {paddingTop: 10}]} >My Account</Text>
<Image source= {require('../images/lawrance.jpg')}
style={styles.avatarStyle}/>
<Text style = {styles.textStyle} > Jenifer Lawrance</Text>
<Text style = {styles.textStyle} > +14155552671</Text>
<Balance style= {styles.balanceContainer}/>
</ImageBackground>
);
}
}
const styles = StyleSheet.create({
container: {
backgroundColor:'red',
opacity: 0.6
},
overlay: {
backgroundColor:'transparent',
opacity: 0.6
},
avatarStyle: {
width:100,
height: 100,
marginTop: 10,
borderRadius: 50,
alignSelf: 'center',
},
textStyle: {
marginTop: 10,
fontSize: 18,
color: "#FFFFFF",
fontWeight: 'bold',
alignSelf: 'center',
},
balanceContainer:{
padding:10,
}
});
export default AccountHeader;
Now here are two issues:
ImageBackground
also change the opacity of its childrenAny help appreciated!
Design screen:
Developed Screen
Specify Opacity of a Color in React If you want to specify the opacity of background color, you should use the rgba() , which is slightly different from rgb() function. The decimal value can be anything from 0 to 1 . In this case, our background will be 30% colored and 70% transparent .
create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: 'white', }, image: { height: 250, width: 250, opacity: 0.5, }, }); export default Home; The output will be as given in the screenshot below. That's how you increase or reduce transparency of image in react native.
Well, you can also change the color of an image or icon in React Native. Precisely saying, you can change the color of all the non-transparent pixels of the image. To achieve this, all you need is to add the style prop tintColor to your image component.
Try this :
<ImageBackground source={require('./images/backgroundBlue.jpg')} imageStyle=
{{opacity:0.5}}/>
it works
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