2017-05-15 31 views
5

我想在我的應用程序中使用FlatList(React-native)。我正在水平使用它並可以看到滾動條。在ScrollView中有一個選項來隱藏滾動條,但不在FlatList中。有沒有人能夠以其他方式隱藏它。我嘗試使用子容器(Hide scroll bar, but still being able to scroll)的父代&的解決方案,但沒有奏效。隱藏滾動條在FlatList(React Native)中Android

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; 
+4

試'showsHorizo​​ntalScrollIndicator = {FALSE}' – Raymond

回答

26

只需添加

showsHorizontalScrollIndicator={false} 
+0

它藉機d,但在官方文件中沒有提到它作爲FlatList的道具。 –

0

嘗試本作的ListView水平加(水平= {真})下文提到的,如果你只想隱藏滾動條只需添加(showsHorizo​​ntalScrollIndicator = {假})

<ListView showsHorizontalScrollIndicator={false} 
         horizontal={true} 

/>