Skip to content

Android wrong height when in full screen with no navigation bar #90

@alwex

Description

@alwex

for full screen image rendering the library use

  const windowDimensions = useWindowDimensions();
  const dimensions = containerDimensions || windowDimensions;

The issue is that useWindowDimensions returns the heigh without the height of the android navigation bar, which means that the image will never render in real fullscreen, but keep a black margin under of the exact size of the navigation bar.

image

For real fullscreen mode, a workaround is to use this instead:

  import {Dimensions as RNDimensions} from 'react-native'

  // ...

  const windowDimensions = useWindowDimensions()
 
  const [dimensionsToUse, setDimensionsToUse] = useState(
    RNDimensions.get('screen')
  )
  useEffect(() => {
    // set the actual screen heigh and not the window height
    setDimensionsToUse(RNDimensions.get('screen'))
  }, 
  // re calculate when device orientation change
  [windowDimensions.height, windowDimensions.width])

  const dimensions = containerDimensions || dimensionsToUse //containerDimensions || windowDimensions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions