Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

314
Visualizações
React Native Listview leaving space

I'm trying to implement a listview in React Native. Everything was fine when I was just calling the component Accounts but since I put it into a NavigatorIOS the Listview is leaving some space before the first item : see here and when I scroll here.

Here is my code :

index.ios.js

var RemoteX1 = React.createClass({

  render: function() {
    return (
      <NavigatorIOS
        style={styles.container}
        initialRoute={{
          title: 'Accounts',
          component: Accounts,
        }}/>
    );
  }
});

var styles = StyleSheet.create({
  container: {
    flex: 1,
  },
});

accounts.js

var people = [
  {
    title: "Papa",
    favouriteChannels: []
  },
  {
    title: "Maman",
    favouriteChannels: []
  },
  {
    title: "Kids",
    favouriteChannels: []
  },
  {
    title: "Invité",
    favouriteChannels: []
  }
];

var Accounts = React.createClass({
  getInitialState: function() {
    var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
    return {
      dataSource: ds.cloneWithRows(people),
    }
  },
  renderRow: function(person) {
    return (
      <TouchableHighlight onPress={this.onPressRow}>
        <Text style={styles.account}>{person.title}</Text>
      </TouchableHighlight>
    );
  },
  render: function() {
    return (
      <View style={styles.container}>
        <View style={styles.panel}>
          <Text style={styles.icon}>&#xF0C6;</Text>
          <Text style={styles.welcome}>BIENVENUE</Text>
          <ListView 
            dataSource={this.state.dataSource}
            renderRow={this.renderRow}
            style={styles.listView} />
        </View>
      </View>
    );
  }
});

var styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center'
  },
  panel: {
    backgroundColor: '#67F072',
    alignItems: 'center',
    justifyContent: 'center',
    paddingLeft: 50,
    paddingRight: 50,
  },
  icon: {
    color: '#67B7F0',
    fontFamily: 'CanalDemiRomainG7',
    fontSize: 40
  },
  welcome: {
    color: '#67B7F0',
    fontFamily: 'CanalDemiRomainG7'
  },
  account: {
    color: '#000000',
    height: 30,
    alignSelf: 'center',
    fontFamily: 'CanalDemiRomainG7'
  },
})

Does anyone has any idea of what's going on ? Thanks

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Ok so, I found the answer, I post it here for anyone who run into the same issue.

An issue has been posted on Github here . It is necessary to add to the ListView the parameter automaticallyAdjustContentInsets={false}. Problem Solved.

over 4 years ago · Santiago Trujillo Relatório

0

This only happens when you have a ScrollView or ListView with TabBarIOS. You can remove the extra space at the top if you put automaticallyAdjustContentInsets={false}

However, the ScrollView will not completely be shown because the bottom portion of it will be hidden under the TabBarIOS. To fix this add contentInset={{bottom:49}} adjust the height according to your needs.

here is the code:

<ListView
  contentInset={{bottom:49}}
  automaticallyAdjustContentInsets={false}
>
over 4 years ago · Santiago Trujillo Relatório

0

If you're trying to achieve this in android..contentInset is iOS specific, to manage this on android you need to set the property inside of <ListView contentContainerStyle={styles.contentContainer}> </ListView>

Then in your stylesheets.create

var styles = StyleSheet.create({
  contentContainer: {
    paddingBottom: 100 
  }

* I realise that op is asking for an iOS solution, just adding the android solution for people passing and if op decides he's fed up with iOS

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda