简体   繁体   English

React Navigation 宽度不是 100% 适合 ios 模拟器上的屏幕

[英]React Navigation width is not 100% fit to screen on ios simulator

When I tried just to render the HomeScreen component not using Stack.Screen I was able to get 100% width but when I tried to use code bellow, 100% width screen is not working当我尝试不使用 Stack.Screen 渲染 HomeScreen 组件时,我能够获得 100% 的宽度,但是当我尝试使用下面的代码时,100% 宽度的屏幕不起作用


const HomeScreen = () => {
    return (
        <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center', backgroundColor: 'red'}}>
            <Text>Home Screen</Text>
        </View>
    );
}

const MainContainer = () => {

    return (
        <NavigationContainer >
            <Stack.Navigator>
                <Stack.Screen
                    name="Home"
                    component={HomeScreen}
                />
            </Stack.Navigator>
        </NavigationContainer>
    );

在此处输入图像描述

Can you try with display: flex and remove flex:1你可以试试 display: flex 和 remove flex:1

Not only that, the width is zero if you set headerShown: false .不仅如此,如果设置headerShown: false ,宽度为零。

Just remove the outer View of the NavigationContainer .只需删除NavigationContainer的外部View即可。 It works for me.这个对我有用。

Were you running the remote debugger when you were having this issue?当您遇到此问题时,您是否正在运行远程调试器? I had the same problem and it resolved when I turned it off.我有同样的问题,当我关闭它时它解决了。

It seems like it might be a slow load issue and the stylesheets aren't being applied before rendering, so the screen is taking the width of the header text (I may be completely wrong about this though).看起来这可能是一个加载缓慢的问题,并且在渲染之前没有应用样式表,所以屏幕占用了 header 文本的宽度(尽管我可能完全错了)。 When I removed the style prop from my View component, saved it, then put it back and saved again it temporarily resolved the issue until I reloaded Expo.当我从我的视图组件中删除样式道具,保存它,然后放回去并再次保存它暂时解决了这个问题,直到我重新加载 Expo。

有没有办法设置<div>宽度到屏幕的 100%?</div><div id="text_translate"><p> 我有一个纯 HTML /CSS 网页。 我制作了一个下拉菜单,但无法将其设置为全宽。</p><p> 这是它的代码笔。</p><p> <a href="https://codepen.io/SynergyOfLife/pen/ExyZdZz" rel="nofollow noreferrer">https://codepen.io/SynergyOfLife/pen/ExyZdZz</a></p><p> 我正在使用 Bootstrap 4.5.2。</p><p> 无论我尝试什么,我的.header div 都不会填充 100% 的宽度。 我希望它填充 100%,下面是示例文本。</p><p> 帮助将不胜感激,谢谢。</p></div> - Is there a way to set the <div> width to 100% of the screen?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何让react-native导航屏填满ios模拟器屏 - How to make react-native navigation screen fill up ios simulator screen React Native 适合长图像以适应屏幕宽度和滚动 - React Native fit long images to screen width and scroll 尝试调整幻灯片的宽度以适合屏幕 - Trying to fit a slideshow width to fit screen 计算器不会缩小以适应屏幕宽度 - Calculator not shrinking to fit screen width 如何使画布 100% 适合屏幕? - how to make canvas 100% fit to the screen? 使用表格宽度使表格内容适合宽度:在CSS中设置100% - Make table content fit to width with table width: 100% set in css 许多100%高度/宽度div-轮播导航? - Numerous 100% Height/Width divs - carousel navigation? 在媒体上导航无法获得100%的宽度 - navigation on media cant get 100% width React Navigation中的Reuse屏幕 - Reuse screen in React Navigation 有没有办法设置<div>宽度到屏幕的 100%?</div><div id="text_translate"><p> 我有一个纯 HTML /CSS 网页。 我制作了一个下拉菜单,但无法将其设置为全宽。</p><p> 这是它的代码笔。</p><p> <a href="https://codepen.io/SynergyOfLife/pen/ExyZdZz" rel="nofollow noreferrer">https://codepen.io/SynergyOfLife/pen/ExyZdZz</a></p><p> 我正在使用 Bootstrap 4.5.2。</p><p> 无论我尝试什么,我的.header div 都不会填充 100% 的宽度。 我希望它填充 100%,下面是示例文本。</p><p> 帮助将不胜感激,谢谢。</p></div> - Is there a way to set the <div> width to 100% of the screen?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM