styles - How to render a star rate component in react-native? -


how can create half colored star?

enter image description here

<image source={require('../star.png')}   style={{     height: '100%',     aspectratio: 1,     tintcolor: 'blue',     backgroundcolor: 'transparent' }} /> 

is possible have background view , use image mask?
tried following fails.

 <view style={styles.container}>     <view style={{       position: 'absolute',       backgroundcolor: 'blue',       width: '80%',       height: '100%'     }} />     <image source={require('../star.png')}        style={{          height: '100%',          aspectratio: 1,          tintcolor: 'transparent',        }} />  </view> 

you can use component this. should find image of star out of stars must filled color , background color of stars must trasparent. assume width of each star 30 in example. should pass rate value prop

export default class starrate extends component {   render() {     return (       <view style={{height: 30, width: 150}}>         <view style={{           position: 'absolute',           backgroundcolor: 'yellow',           height: 30,             width: this.props.rate*30,         }} />         <image source={require('../star.png')}            style={{             position: 'absolute',             left: 0,             top: 0,             height: 30,             width: 150,            }} />      </view>     );   } } 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -