React Native Image 不适用于android google maps 自定义视图

问题描述

我在谷歌地图中的标记上连续显示五颗星的评级。它在 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 工作:

ios

安卓不工作

android

解决方法

我确实认为这是 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> ); };

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...