【问题标题】:How to make it horizontal scrollable如何使其水平滚动
【发布时间】:2021-05-24 08:27:29
【问题描述】:

下面的代码即使在 flatList 中提及也不显示水平滚动 我也删除了不必要的导入

主屏幕


const firstCategory = categories.items[0];

const HomeScreen = () => {
  return (
    <View style={styles.container}>
        <FlatList
          horizontal={true}
          data={firstCategory.movies}
          renderItem={({item}) => (
            <Image style={styles.image} source={{ uri: item.poster }}/>
          )}   
        />
    </View>
  );
}

export default HomeScreen;

我无法整理,请帮忙! Screenshot

【问题讨论】:

  • 你能把你添加到容器和图像的样式也附加上吗?

标签: react-native react-native-flatlist horizontal-scrolling


【解决方案1】:
    <FlatList
      horizontal
      data={firstCategory.movies}
      renderItem={({item}) => (
        <Image style={styles.image} source={{ uri: item.poster }}/>
      )}   
      keyExtractor={(item, index) => index}
    />

尝试使用这个

【讨论】:

    【解决方案2】:

    在我看来,使用 React Native 图片由于某种原因不显示是一个常见问题。通常有两个主要问题需要考虑。 来源道具和尺寸。

     <FlatList  horizontal={true}
              data={firstCategory.movies}
              renderItem={({item}) => (
           <Image style={styles.image} source={{ uri: item.poster }}/> )} 
                showsHorizontalScrollIndicator={true} 
    
                keyExtractor={(item, index) => index}
            />`
    
    
    
      
    

    enter image description here

    【讨论】:

      猜你喜欢
      • 2021-08-25
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      • 2017-09-12
      • 1970-01-01
      • 2021-09-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多