• <small id='I8Jcz'></small><noframes id='I8Jcz'>

      <i id='I8Jcz'><tr id='I8Jcz'><dt id='I8Jcz'><q id='I8Jcz'><span id='I8Jcz'><b id='I8Jcz'><form id='I8Jcz'><ins id='I8Jcz'></ins><ul id='I8Jcz'></ul><sub id='I8Jcz'></sub></form><legend id='I8Jcz'></legend><bdo id='I8Jcz'><pre id='I8Jcz'><center id='I8Jcz'></center></pre></bdo></b><th id='I8Jcz'></th></span></q></dt></tr></i><div id='I8Jcz'><tfoot id='I8Jcz'></tfoot><dl id='I8Jcz'><fieldset id='I8Jcz'></fieldset></dl></div>
      <legend id='I8Jcz'><style id='I8Jcz'><dir id='I8Jcz'><q id='I8Jcz'></q></dir></style></legend>
        <bdo id='I8Jcz'></bdo><ul id='I8Jcz'></ul>
      1. <tfoot id='I8Jcz'></tfoot>

        React Native 选项卡视图的高度始终等于最高选项卡的高度

        React Native Tab view always has the height equal to height of the highest tab(React Native 选项卡视图的高度始终等于最高选项卡的高度)

      2. <i id='C9xER'><tr id='C9xER'><dt id='C9xER'><q id='C9xER'><span id='C9xER'><b id='C9xER'><form id='C9xER'><ins id='C9xER'></ins><ul id='C9xER'></ul><sub id='C9xER'></sub></form><legend id='C9xER'></legend><bdo id='C9xER'><pre id='C9xER'><center id='C9xER'></center></pre></bdo></b><th id='C9xER'></th></span></q></dt></tr></i><div id='C9xER'><tfoot id='C9xER'></tfoot><dl id='C9xER'><fieldset id='C9xER'></fieldset></dl></div>
        <legend id='C9xER'><style id='C9xER'><dir id='C9xER'><q id='C9xER'></q></dir></style></legend><tfoot id='C9xER'></tfoot>
            <bdo id='C9xER'></bdo><ul id='C9xER'></ul>
                <tbody id='C9xER'></tbody>

                <small id='C9xER'></small><noframes id='C9xER'>

                1. 本文介绍了React Native 选项卡视图的高度始终等于最高选项卡的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个在其页脚中呈现选项卡视图的 FlatList.此选项卡视图允许用户在一个 FlatList 或另一个之间切换.所以,最后这些是同级 FlatLists.

                  I have a FlatList that renders a Tab View in its footer. This Tab View let the user switch between one FlatList or an other. So, these last are sibling FlatLists.

                  第一个平面列表A";具有比第二个B"更大的高度.当我选择第二个列表时,它的高度与A"相同.FlatList 的一个.

                  The first FlatList "A" has a greater height than the second one "B". When I choose the second list, its height is the same as the "A" FlatList's one.

                  我在 snack 中重现了该问题,您可以在其中看到类似的代码.我承认代码有点长但是太简单了,只关注父 FlatList(在 App 组件中)和每个选项卡中呈现的两个 FlatList(在代码末尾)

                  I have reproduced the problem in a snack where you can see a similar code. I recognize that the code is a little long but too simple, just focus only on the parent FlatList (in the App component) and the two FlatLists that are rendered in each tab (at the end of the code)

                  任何想法如何解决这个问题?我不知道问题出在样式上,还是我必须做其他事情才能完成这项工作(所有平面列表都必须有自己的高度,而不是更大的高度).

                  Any ideas how to solve this issue? I don't know if the problem is in the styles or if I have to do something else to make this work (all flatlists have to have their own height, not the greater).

                  谢谢你,非常感谢你的帮助.

                  Thank you, I would really appreciate your help.

                  推荐答案

                  我已经用解决方案更新了零食!

                  I have updated the snack with the solution!

                  就像在我实现自己的 TabView 的零食中一样,我决定使用库react-native-tab-view"实现相同的解决方案,因为它是目前反应原生的最佳选项卡.

                  As in the snack I implemented my own TabView, I have decided to implement the same solution with the library "react-native-tab-view", as it is the best tab for react native for now.

                  认为有些人有这个问题能解决的.

                  Think that some people having this issue will be able to solve it.

                  基本上,我们需要做的是动态计算每个选项卡场景的高度,并使用 onLayout 属性将其传递给 TabView 的样式.

                  Basically, what we need to do is to dinamically calculate the height of each tab scene and pass it to the style of the TabView using the onLayout prop.

                  就像这样:

                   const renderScene = ({ route }) => {
                      switch (route.key) {
                        case "inifiniteScrollFlatList":
                          return (
                            <FirstRoute />
                          );
                        case "rawDataFlatList":
                          return (
                            <View
                              onLayout={(event) => setTab1Height(event.nativeEvent.layout.height + TAB_HEIGHT)}
                            >
                              <SecondRoute />
                            </View>
                          );
                        case "otherRawDataFlatList":
                          return (
                            <View
                              onLayout={(event) => setTab2Height(event.nativeEvent.layout.height + TAB_HEIGHT)}
                            >
                              <ThirdRoute />
                            </View>
                          );
                        default:
                          return null;
                      }
                    };
                  
                    <TabView
                        style={ index !== 0 && {
                          height: index === 1 ? tab1Height : tab2Height,
                        }}
                        renderTabBar={renderTabBar}
                        navigationState={{ index, routes }}
                        renderScene={renderScene}
                        onIndexChange={setIndex}
                        initialLayout={initialLayout}
                        removeClippedSubviews={false} // Pd: Don't enable this on iOS where this is buggy and views don't re-appear.
                        swipeEnabled={true}
                    />
                  

                  Pd:您不应该对使用无限滚动和分页的选项卡执行此操作.相反,您必须将高度设置为 null 以允许父 FlatList 自动获取其高度.

                  Pd: You shouldn't do this with a tab that uses an infinite scroll with pagination. Instead, you will have to set the height to null to allow the parent FlatList to automatically get its height.

                  这篇关于React Native 选项卡视图的高度始终等于最高选项卡的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Move link image 5px up on hover(悬停时将链接图像向上移动 5px)
                  How do I inspect CSS pseudo classes with firebug?(如何使用 firebug 检查 CSS 伪类?)
                  Why doesn#39;t CSS hover work on table rows when the cells inside the rows have class names?(当行内的单元格具有类名时,为什么 CSS 悬停在表格行上不起作用?)
                  Hover image - display div over it(悬停图像 - 在其上显示 div)
                  How to apply a CSS class on hover to dynamically generated submit buttons?(如何在悬停时将 CSS 类应用于动态生成的提交按钮?)
                  Differences between CSS3 :hover and :focus?(CSS3 :hover 和 :focus 的区别?)

                      <i id='Ns4bI'><tr id='Ns4bI'><dt id='Ns4bI'><q id='Ns4bI'><span id='Ns4bI'><b id='Ns4bI'><form id='Ns4bI'><ins id='Ns4bI'></ins><ul id='Ns4bI'></ul><sub id='Ns4bI'></sub></form><legend id='Ns4bI'></legend><bdo id='Ns4bI'><pre id='Ns4bI'><center id='Ns4bI'></center></pre></bdo></b><th id='Ns4bI'></th></span></q></dt></tr></i><div id='Ns4bI'><tfoot id='Ns4bI'></tfoot><dl id='Ns4bI'><fieldset id='Ns4bI'></fieldset></dl></div>

                      <legend id='Ns4bI'><style id='Ns4bI'><dir id='Ns4bI'><q id='Ns4bI'></q></dir></style></legend>
                    1. <tfoot id='Ns4bI'></tfoot>

                      <small id='Ns4bI'></small><noframes id='Ns4bI'>

                          <tbody id='Ns4bI'></tbody>
                        • <bdo id='Ns4bI'></bdo><ul id='Ns4bI'></ul>