如何将Stack.Screen中的内容垂直居中,包括将标头放入计算中?

问题描述 投票:0回答:1

如何将Stack.Screen中的内容包括标头垂直居中?

[当前,如果我尝试使元素在屏幕上垂直居中,由于Stack.Screen标头,它会稍微移到屏幕底部。我想在不使用Stack.Screen的情况下计算此大小,其中margin-top: -N是标题的大小。

为什么没有边距?因为它增加了处理iOS和Android设备的复杂性。

navigator.component.tsx

N

sign.in.component.tsx

<Stack.Navigator>
  <Stack.Screen
    name='SignIn'
    component={SignInComponent}
  />
</Stack.Navigator>

const SignInComponent = () => { return ( <View style={{ height: '100%', justifyContent: 'center' }}> <Text>Example</Text> </View> ) } React-navigation screenshot #1

react-native react-navigation
1个回答
1
投票

为什么没有边距?因为它增加了处理iOS和Android设备的复杂性。

© www.soinside.com 2019 - 2024. All rights reserved.