【问题标题】:enable scroll in Scrollview在 Scrollview 中启用滚动
【发布时间】:2020-06-29 00:21:51
【问题描述】:

所以我创建了一个包含多个视图的 ScrollView,但滚动不起作用并且我无法显示其他视图,有人知道我该怎么做或我的代码有什么问题吗? 这是我的代码

import React from 'react'
import {ScrollView,View,Text,Button,StyleSheet,FlatList,Image} from 'react-native'
export default function MedProfilScreen({route}){
    const {name,specialite,work}=route.params;
    return(
      <ScrollView contentContainerStyle={{flex:1,alignItems:'center'} } >
        <View style={styles.ctr1}>
        <Image style={styles.img} source={require('../assets/Title.jpg')} />
          <Text style={styles.txt}>{name}</Text>
          <Text style={styles.txt}>{specialite}</Text>
          <Text style={styles.txt}>{work}</Text>
          <Button title='Prendre rendez-vous' onPress={()=>{}} />
        </View>
        <View>
          <Text>fgfg</Text>
          <Text>fgfg</Text>
          <Text>fgfg</Text>
          <Text>fgfg</Text>
          <Text>fgfg</Text>
        </View>
      </ScrollView>
    );

}

【问题讨论】:

    标签: reactjs react-native ecmascript-6


    【解决方案1】:

    从你的 contentContainerStyle 中移除 flex:1,使用它就像这样做

    <ScrollView>
      <View style={{ flex: 1 }}>
       some content
      </View>
    <ScrollView>
    

    最终只占用可用空间并删除滚动功能,因为内容不大于其容器

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-19
      • 2021-04-19
      • 2019-11-02
      相关资源
      最近更新 更多