5

I have a react native component like:

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

import Level from './Level';

class LevelList extends Component {
    render() {

        return (
            <ScrollView style={styles.scrollView} >
                <View style={styles.levelList}>
                    <Level />
                    <Level />
                    <Level />
                    <Level />
                    <Level />
                    <Level />
                </View>
            </ScrollView>
        )
    }
}

var styles = StyleSheet.create({
    scrollView: {
    backgroundColor: '#fff',
    flex: 1,
    },
    levelList: {
        marginTop: 50,
        flexDirection:'column',
        alignItems: 'center',
    },

})

export default LevelList;

Here <Level> is simply a component that holds a text.

I have <LevelList> in my container like:

class LevelListView extends Component {
    render() {
        return (
            <View style={{flex: 1}}>
                <Header />
                <LevelList />
            </View>
        )
    }
}

export default LevelListView

Here I get a scrollbar in the side of my list but it does not get scrolled. What am I missing here ?

I am running the app in emulator:

Update:

import React, { Component } from 'react';

import { StyleSheet, Text, View } from 'react-native';

class Header extends Component {
    render() {
        return (
            <View style={styles.toolbar}>
                <Text style={styles.toolbarBack}>Back</Text>
                <Text style={styles.toolbarTitle}>Levels</Text>
            </View>
        )
    }
}

var styles = StyleSheet.create({
    toolbar:{
        backgroundColor:'#00bcd4',
        paddingTop:10,
        paddingBottom:10,
        flexDirection:'row'
    },
    toolbarTitle:{
        color:'#fff',
        textAlign:'center',
        fontSize:20,
        fontWeight:'bold',
        marginRight: 30,
        flex:1
    },
    toolbarBack: {
        color: '#fff',
        fontSize: 14,
        fontWeight: 'bold',
        marginTop: 4,
        marginLeft: 10,
    }
})

export default Header;
8
  • Hey, share 'Header' component code.. Commented May 26, 2016 at 7:45
  • @Jickson I have added the Header component Commented May 26, 2016 at 8:07
  • Hey, I tried your code.. Its working here. Issue is in some other component i guess.. Commented May 26, 2016 at 8:10
  • @Jickson I have only 2 component out there header and levellist.... You tried on emulator ?? Commented May 26, 2016 at 8:14
  • Yes. I have tried on Android emulator.. Commented May 26, 2016 at 8:15

2 Answers 2

4

I had the same problem and tried everything on the internet like flex:1 solutions... But the problem is, Android is not letting you use nested scroll with scrollview. I just put:

nestedScrollEnabled={true} 

Command to my scrollview object and it worked like a charm.

Sign up to request clarification or add additional context in comments.

Comments

0

I had the similar problem but I resolved it by doing this:

<ScrollView style={{ 

    height:Dimensions.get('screen').height

    }}>
       ///
    </ScrollView>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.