I use react native to develop my app. I want to show Image full screen but my code let Screen of my app change position when status bar hidden.
const myApp = () => {
const [hiddenStatusBar, setHiddenStatusBar] = useState()
const onClickImage = useCallback(() => {
if (hiddenStatusBar) {
setHiddenStatusBar(false)
} else {
setHiddenStatusBar(true)
}
}, [hiddenStatusBar])
return(
<View style={{ flex: 1 }}>
<Pressable onPress={onClickImage}>
<Image source={{ uri: item?.uri }}
style={{ width: mobileWidth, height: mobileHeight }}
contentFit="cover"
/>
</Pressable>
<StatusBar hidden={hiddenStatusBar} animated={true} />
</View>
)
}
What i want:
But my code output:
Can someone help me, thank you!


StatusBarManager.HEIGHTwill return the fixed height of the status bar.top: hiddenStatusBar ? 0 : -StatusBarManager.HEIGHTWhen the status bar is visible, the
ImageBackgroundis shifted to the top by an offset equal to the status bar height. This maintains the image ratio to be the same both before and after.With these two fixes, the resizing flicker issue gets hidden, as the image ratio is maintained in both the states.