React Native获取手机的各种高度

一、窗口高度

即图中黄色+蓝色部分

import { Dimensions } from "react-native";
const deviceHeight = Dimensions.get('window').height;  

二、屏幕高度

即图中黄色+蓝色+红色部分

import { Dimensions } from "react-native";
const deviceHeight = Dimensions.get('screen').height;  

三、内容高度

即图中蓝色部分

import { StyleSheet, View, Text, ScrollView, Dimensions, PanResponder, StatusBar } from "react-native";
const deviceHeight = Dimensions.get('window').height;  
const STATUS_BAR_HEIGHT = StatusBar.currentHeight; //即图中黄色部分
const height = deviceHeight  - STATUS_BAR_HEIGHT;

相关文章:

  • 2021-11-01
  • 2021-12-15
  • 2021-12-26
  • 2022-01-09
  • 2021-12-19
  • 2021-12-25
  • 2021-11-30
  • 2022-12-23
猜你喜欢
  • 2021-10-11
  • 2022-12-23
  • 2021-11-04
  • 2022-12-23
  • 2022-12-23
  • 2021-11-01
相关资源
相似解决方案