我想实现全屏垂直滑块的行为。我已经添加了pagingEnable
道具,FlatList
但它不能正常工作。
下面是我的代码。
请将此图片作为参考:https ://drive.google.com/file/d/1Z1-0jDDZ5rqBvbqMcw2XytHVUhROkG2o/view?usp=sharing
import React from 'react';
import {View, Text, FlatList, Dimensions} from 'react-native';
const {width, height} = Dimensions.get('window');
const VerticalSlider = () => {
const renderItem = ({item, index}) => {
return (
<View
style={{
backgroundColor: item,
alignItems: 'center',
justifyContent: 'center',
height: height,
}}>
<Text style={{color: '#FFF', fontWeight: 'bold', fontSize: 30}}>
{index}
</Text>
</View>
);
};
return (
<FlatList
pagingEnabled
data={['red', 'green', 'blue', 'pink']}
renderItem={renderItem}
keyExtractor={(item, index) => String(index)}
bounces={false}
/>
);
};
export default VerticalSlider;