【问题标题】:ScrollView not working with SimpleAccordian view/ScrollView 不适用于 SimpleAccordian 视图/
【发布时间】:2020-10-26 02:25:46
【问题描述】:

我正在尝试使用组件创建 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-native react-native-scrollview


    【解决方案1】:

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

    contentContainerStyle = {{
          flexGrow:1
    }}
    

    【讨论】:

    • 我试过用这个: 但对结果没有影响。
    • 暂时移除 SimpleAccordian 视图,并为 scrollView 提供背景颜色并查看它占用了多少区域,当 ScrollView 全屏显示后,将您的 SimpleAccordian 视图放回原位
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多