【问题标题】:Tab Screens Missing for React-Native AndroidReact-Native Android 缺少选项卡屏幕
【发布时间】:2018-09-10 12:51:13
【问题描述】:

我正在使用包 react-native-tab-view 在屏幕中间呈现一个选项卡小部件。小部件在 iOS 上正确呈现,但在 Android 上缺少屏幕。这个小部件出现在屏幕中间,上面和下面都有材料,所有这些都被包裹在一个类似这样的 ScrollView 中(为简洁起见,未显示其他材料):

<View style={styles.container}>
    <ScrollView style={{ backgroundColor: primaryLightBlue2Color }}>
        <View style={{paddingVertical: 10}}>
            <MemberSummary />
            <View style={{ marginTop: 20 }} />

            <TabView
                navigationState={this.state}
                renderScene={this.renderScene}
                renderTabBar={this.renderTabBar}
                onIndexChange={this.handleIndexChange}
                tabStyle={styles.tabbar}
            />

            {this.spendingAccountsExist()}
        </View>
    </ScrollView>
</View>

正如我提到的,与选项卡关联的屏幕不显示

那么,我是否做错了他们没有显示的事情,或者小部件不是为我想要做的事情而设计的?

【问题讨论】:

    标签: android react-native tabs


    【解决方案1】:

    我发现了可以在这里找到的答案:https://github.com/react-native-community/react-native-tab-view/issues/537#issuecomment-395359494

    总而言之,对于 Android,请确保您的 TabView 组件具有这样的 renderPager:

    _renderPager = (props) => <PagerPan {...props} />
    

    <TabView
        navigationState={this.state}
        renderScene={this._renderScene}
        renderTabBar={this._renderTabBar}
        onIndexChange={this._handleIndexChange}
        renderPager={this._renderPager}
        tabStyle={styles.tabbar}
    />
    

    【讨论】:

    • 这对我有用,我的代码中没有renderPager,谢谢
    • 从哪里导入 PagerPan?
    猜你喜欢
    • 2019-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-10
    • 1970-01-01
    • 1970-01-01
    • 2021-09-21
    • 1970-01-01
    相关资源
    最近更新 更多