Screen width in React Native

前端 未结 10 939
独厮守ぢ
独厮守ぢ 2020-12-13 08:33

How do I get screen width in React native?

(I need it because I use some absolute components that overlap and their position on screen changes with different device

10条回答
  •  -上瘾入骨i
    2020-12-13 08:53

    Only two simple steps.

    1. import { Dimensions } from 'react-native' at top of your file.
    2. const { height } = Dimensions.get('window');

    now the window screen height is stored in the height variable.

提交回复
热议问题