问题描述
我在谷歌地图中的标记上连续显示五颗星的评级。它在 iO 上运行良好,但在 Android 上没有加载图像。我不明白为什么,因为我能够在整个应用程序的其余部分使用该标签。在谷歌地图上显示自定义图像似乎只是一个问题。
资产路径正确。我尝试导入图像以及使用 uri url。似乎没有什么在 android.这是唯一有问题的页面...
这是一个已知问题吗?
const styles = StyleSheet.create({
container: {
backgroundColor: Colors.Transparent,flexDirection: "row",flex: 1,alignSelf: "center",},image: {
width: 25,height: 25,});
const Starrating = props => {
let rating = props.ratingValue;
console.log("rating",rating);
return (
<View style={styles.container}>
<Image style={styles.image} source={require("assets/star-filled.png")} />
<Image style={styles.image} source={require("assets/star-filled.png")} />
<Image style={styles.image} source={require("assets/star-filled.png")} />
<Image style={styles.image} source={require("assets/star-filled.png")} />
<Image style={styles.image} source={require("assets/star-filled.png")} />
</View>
);
};
ios 工作:
解决方法
我确实认为这是 Android 上的一个错误,即 Callout 组件无法在 IOS 上渲染图像。
对于这种情况,我看到您要做的就是在标注组件中渲染五颗星。 好消息是使用 expo/vector-icons 可以获得同样的东西。 我的意思是你可以像这样重写你的代码:
const StarRating = props => { let rating = props.ratingValue; console.log("rating",rating); return ( <View style={styles.container}> <Ionicons name="star" size={10}/> <Ionicons name="star" size={10}/> <Ionicons name="star" size={10}/> <Ionicons name="star" size={10}/> <Ionicons name="star" size={10}/> </View> ); };