首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >响应导航v6堆栈导航器headerLargeTitle太快崩溃

响应导航v6堆栈导航器headerLargeTitle太快崩溃
EN

Stack Overflow用户
提问于 2021-08-30 19:59:52
回答 1查看 1.2K关注 0票数 5

在我的应用程序中,我尝试使用反应导航的堆栈导航器并启用headerLargeTitleheaderTransparent

我的实现如下所示:

Navigator.tsx

代码语言:javascript
复制
<HomeStack.Navigator
  initialRouteName="ScreenA"
  screenOptions={({ navigation, route }) => ({
    title: 'My app',
    headerTransparent: true,
    headerBlurEffect: 'light',
    headerLargeTitleShadowVisible: false,
    headerLargeTitle: true,
    headerSearchBarOptions: {
      autoCapitalize: 'none',
      obscureBackground: false,
    },
  })}
>
  <HomeStack.Screen
    name="ScreenA"
    component={ScreenA}
  />
</HomeStack.Navigator>

ScreenA返回:

代码语言:javascript
复制
const headerHeight = useHeaderHeight();

return (
<>
  {isReady && (
    <ScrollView
      contentInset={{
        top: headerHeight * 2,
      }}
      style={{
        backgroundColor: 'red',
      }}
    >
      <View.Base
        style={{
          height: 900,
          width: '100%',
          backgroundColor: 'yellow',
        }}
      />
    </ScrollView>
  )}
</>
);

这目前产生以下输出:

视频示例

正如你所看到的,标题崩溃得太快了,我不知道为什么,可悲的是。

当将headerTransparent设置为false时,它有一个问题,即崩溃效应不能“停止”,所以这里有一些东西不存在。

而且,headerHeight似乎没有返回大标题标题的正确高度。我不确定这和这件事有关。

EN

回答 1

Stack Overflow用户

发布于 2021-12-14 11:53:57

而且,headerHeight似乎没有返回大标题标题的正确高度。我不确定这和这件事有关。

是的,useHeaderHeight()返回的值似乎没有考虑到大的头。

这两个问题都应该通过将ScrollView上的属性ScrollView设置为"automatic"来解决。如下所示:

代码语言:javascript
复制
const headerHeight = useHeaderHeight();

return (
  <>
    {isReady && (
      <ScrollView
        contentInsetAdjustmentBehavior="automatic"
        style={{
          backgroundColor: 'red',
        }}
      >
        <View.Base
          style={{
            height: 900,
            width: '100%',
            backgroundColor: 'yellow',
          }}
        />
      </ScrollView>
    )}
  </>  
);
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68989690

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档