2017-05-15 16 views
5

Próbuję użyć FlatList (native-React) w mojej aplikacji. Używam go poziomo i widzę pasek przewijania. Istnieje opcja w ScrollView, aby ukryć pasek przewijania, ale nie w FlatList. Czy ktoś był w stanie to ukryć w inny sposób. Próbowałem użyć rozwiązania rodzica & kontenera dla dzieci (Hide scroll bar, but still being able to scroll), ale nie działało.Ukryj pasek przewijania w FlatList (React Native) w Androidzie

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

try 'showsHorizontalScrollIndicator = {false}' – Raymond

Odpowiedz

26

Wystarczy dodać

showsHorizontalScrollIndicator={false} 
+0

To worke d ale nie jest wspomniany w oficjalnym dokumencie jako propozycja dla FlatList. –

0

spróbować to zrobić ListView poziomego add (poziomo = {true}) wymienione poniżej, a jeśli po prostu chcesz, aby ukryć pasek przewijania po prostu dodać (showsHorizontalScrollIndicator = {false})

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

/>

Powiązane problemy