react-native - FlatList 中的水平滚动 - React Native
问题描述
我正在使用 flatlist 列出数据。但是在列出数据时,它垂直列出,我希望它水平排序。所以我不想向下滚动,而是想左右滚动。我认为它称为 pagingEnabled。我怎样才能做到这一点?
<FlatList
style={{
flex: 1
}}
showsVerticalScrollIndicator={false}
showsHorizontalScrollIndicator={false}
data={this.state.allReasons}
keyExtractor={(item,index)=>index.toString()}
renderItem={({ item ,index}) => {
return (
<ScrollView onScroll={(event)=>{
this.setState({
activePage:Math.round(parseFloat(event.nativeEvent.contentOffset.x/Dimensions.get('window').width))
})
}}
style={{width:'100%'}} showsHorizontalScrollIndicator={false} pagingEnabled={true} horizontal={true}>
<View style={{width:'100%'}}>
<Image style={{ resizeMode: 'contain',width:Dimensions.get('window').width,height:250}} source={{uri:"http://ledslider.stechomeyazilim.com/" + item.Slider_Image}}/>
.....
</View>
解决方案
在 Flatlist 中添加水平道具,如
horizontal={true}
尝试从项目中删除滚动视图可能会导致问题
推荐阅读
- laravel - 如何使用 Laravel 使用查询生成器在左连接中添加附加条件
- asp.net-core - 主域和受信任域之间的信任关系因 ClaimsTransformer 失败
- python - 无法从长地址中挖出所需的地址部分
- python - 如何覆盖函数内的全局变量?
- ms-access - 访问我如何创建一个显示有多少相同的报告,包括如果只有 1
- c# - PredicateBuilder 不适用于 Where 子句
- laravel - 如何使用 Laravel Eloquent updateOrCreate() 增加列?
- c++ - DirectX:即使我的系统表示支持,也无法创建 directx11 设备
- pandas - 如何利用DataFrame的优势扩展输入
- python - 为什么当我将代码放入服务器时,translator.detect(..).lang 给了我异常,而它在我的本地主机上运行良好