【问题标题】:Hide shadow under react-navigation header在反应导航标题下隐藏阴影
【发布时间】:2020-10-01 14:12:16
【问题描述】:

我尝试使用海拔 0 属性隐藏标题阴影。

在 Android 10 上,它不起作用。标题是灰色的。 在其他版本中,它可以工作。

我正在使用 React Navigation V5。

高度为 0 的 Android 10:

没有海拔 0 的 Android 10:

高度为 0 的 Android 8.1:

我的代码:

<Stack.Navigator>
      <Stack.Screen
        name="DiscountsReleaseDetail"
        component={DiscountsReleaseDetail}
        options={({ navigation, route }) => {
          const { numSeq, codMaquina } = route.params.order;
          return {
            headerTitle: `Pedido ${numSeq}/${codMaquina}`,
            headerTitleAlign: 'center',
            headerBackTitleVisible: false,
            headerTintColor: '#fff',
            headerStyle: {
              backgroundColor: colorCompany,
              shadowOpacity: 0, // remove shadow on iOS
              elevation: 0, // remove shadow on Android
            },
            headerLeft: () => (
              <HeaderButtonBack
                onPress={() => {
                  navigation.reset({
                    index: 0,
                    routes: [{ name: 'DiscountsRelease' }],
                  });
                }}
              />
            ),
          };
        }}
      />
</Stack.Navigator>

【问题讨论】:

  • 可能是 lib 本身的问题,建议在 GitHub repo 中开一个新的 issue

标签: react-native react-navigation


【解决方案1】:

试试这个设置。为我工作。

headerStyle: {
backgroundColor: "black",
shadowOpacity: 0,
shadowOffset: {
    height: 0,
},
shadowRadius: 0,
elevation: 0}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-08
    • 1970-01-01
    • 2018-03-27
    • 1970-01-01
    • 2019-06-09
    相关资源
    最近更新 更多