首页 > 解决方案 > ScrollView 不适用于 SimpleAccordian 视图/

问题描述

我正在尝试使用组件创建一个 Accordian:来自 library:'react-native-simple-accordian'。但是当手风琴标题的数量更多时,我看不到 ScrollView 正常工作。

我的代码:

<View style={{flex:1}}>
        <ScrollView style={{flex:1}}>
            <View style={styles.container}>
                
                        <SimpleAccordion
                            style= {{
                              borderWidth:1,
                              borderRadius:15,
                              margin:3,
                              padding:5,
                              backgroundColor:'#ffffff'
                            }}
                            sections={sectionData}
                            renderHeader= {this.renderHeader}
                            renderContent={this.renderContent}
                            duration={1000}
                            touchableComponent={TouchableOpacity}
                            onChange={this.onChangeAccordian.bind(this)}
                            activeSection={this.state.open}
                        />
            </View>
        </ScrollView>
        </View>

样式对象是这样的:

container: {
      flex: 1,
      justifyContent: 'center',
    },

我在这里为 ScrollView 做错了什么样式或定位?反应式

标签: react-nativereact-native-scrollview

解决方案


在 react-native ScrollView 的情况下,您可能需要在“contentContainerStyle”道具中提供样式,并且您可能还需要将 flexGrow 的样式属性设置为 1

contentContainerStyle = {{
      flexGrow:1
}}

推荐阅读