我试图创建一个圆圈,里面有一个图像,它的边框是彩色的,这就是我使用 LinearGradient 的原因。
我正在使用这个指南:
https://codeburst.io/linear-gradient-for-border-color-in-react-native-5bcab3eea1c9 https://codeburst.io/linear-gradient-for-border-color-in-react-native-5bcab3eea1c9
问题是,在 iOS 中它工作正常,如下图所示:
https://i.stack.imgur.com/oNBRG.jpg https://i.stack.imgur.com/oNBRG.jpg
但是在android上,当我使用borderWidth并选择透明的borderColor时,borderColor看起来像阴影并且由于某种原因没有选择LinearGradient颜色......
这是安卓:https://i.stack.imgur.com/F7r3n.jpg https://i.stack.imgur.com/F7r3n.jpg
我究竟做错了什么?
<LinearGradient
colors={['#ac8af8', '#cca5e7']}
start={{ x: 0.0, y: 1.0 }} end={{ x: 1.0, y: 1.0 }}
style={styles.profilePhotoContainer}
>
<TouchableOpacity onPress={this.handleEditProfileImage.bind(this)}>
<Image
style={[styles.profileImage]}
source={this.state.profilePhoto}
/>
</TouchableOpacity>
</LinearGradient>
const styles = StyleSheet.create({
profilePhotoContainer: {
zIndex: 5,
position: 'absolute',
top: Dimensions.get('window').height * .13,
left: Dimensions.get('window').width / 2 - Dimensions.get('window').width * .13,
elevation: 4,
borderRadius: 75,
borderWidth: 4,
overflow: "hidden" ,
borderColor: 'transparent',
},
profileImage: {
zIndex: 5,
width: 100,
height: 100,
borderWidth: 1,
borderColor: 'transparent',
backgroundColor: '#FFF',
flex:1,
resizeMode:'contain',
},
})