Screen width in React Native

前端 未结 10 946
独厮守ぢ
独厮守ぢ 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条回答
  •  轮回少年
    2020-12-13 09:14

    Step 1:- Import "Dimensions" api from 'react-native'

    import { Dimensions } from 'react-native';
    

    Step 2:- Get Dimensions (Window width/height)

    const { width, height } = Dimensions.get("window");
    

    Step 3:- Use width and height variable.

    
    test               
    
    

提交回复
热议问题