gpt4 book ai didi

react-native - 在 Android 中隐藏 FlatList (React Native) 中的滚动条

转载 作者:行者123 更新时间:2023-12-03 07:28:59 25 4
gpt4 key购买 nike

我正在尝试在我的应用程序中使用 FlatList (React-native)。我水平使用它并且可以看到滚动条。 ScrollView 中有一个隐藏滚动条的选项,但 FlatList 中没有。有没有人能够以其他方式隐藏它。我尝试使用父子容器( Hide scroll bar, but still being able to scroll )的解决方案,但没有成功。

import React, { Component } from 'react';
import { Text, View, FlatList, StyleSheet, ScrollView } from 'react-native';
import { Card, Button } from 'react-native-elements';

const data = [
{ id: 1, title: 'title 1', details: 'details 1 details 1 details 1' },
{ id: 2, title: 'title 2', details: 'details 2 details 2 details 2 details 2 details 2 details 2' },
{ id: 3, title: 'title 3', details: 'details 3 details 3' },
{ id: 4, title: 'title 4 title 4', details: 'details 4' },
];
class CategoryRow extends Component {

_keyExtractor = (item, index) => item.id;

_renderItem = (item) => {
return (
<Card style={styles.cardContainer}>
<Text>{item.title}</Text>
<Text>{item.details}</Text>
</Card>
);
}

render() {
return (
<View style={{ flex: 1, overflow:'hidden' }}>
<View style={{ overflow:'hidden' }}>
<Text>Category 1</Text>
<FlatList
horizontal
data={data}
renderItem={({ item }) => this._renderItem(item)}
keyExtractor={this._keyExtractor}

/>
</View>
</View>
);
}
}

const styles = StyleSheet.create({
cardContainer: {
width: 140,
height: 150,
borderWidth: 0.5,
borderColor: 'grey',
overflow: 'scroll',
},
})

export default CategoryRow;

最佳答案

只需添加

showsHorizontalScrollIndicator={false}

关于react-native - 在 Android 中隐藏 FlatList (React Native) 中的滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43987917/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com