如何使BottomTabNavigator不覆盖滚动视图?

时间:2019-06-13 11:44:19

标签: react-native realm

enter image description here

如何使滚动视图适合屏幕?

        return(
                    <ScrollView scrollEnabled contentContainerStyle = {{marginBottom: 'auto'}}>
                        {this.state.bills.map(bill => {
                            return(
                                <Bill bill = {bill} key = {bill.id} />
                            )
                        })}
                    </ScrollView>

2 个答案:

答案 0 :(得分:0)

使用{flex:1}在视图内覆盖滚动视图, 这对我的应用程序有帮助

export default class App extends React.Component {
  render() {
    return (
      <View style={styles.main}>
        <ScrollView scrollEnabled contentContainerStyle = {{marginBottom: 'auto'}}>
                        {this.state.bills.map(bill => {
                            return(
                                <Bill bill = {bill} key = {bill.id} />
                            )
                        })}
                    </ScrollView>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  main: {
   flex: 1   
  }
});

答案 1 :(得分:0)

使用SafeAreaView包裹滚动视图,如下所示:

<SafeAreaView style={{flex:1}}>
  <ScrollView ...>...</ScrollView>
</SafeAreaView>