How to check an Android device is HDPI screen or MDPI screen?

前端 未结 7 2221
你的背包
你的背包 2020-11-27 09:27

I want to check this to fetch different images by internet. How to do that?

7条回答
  •  天命终不由人
    2020-11-27 10:10

    For React Native to check which size is currently of device

    import { PixelRatio } from 'react-native';   
     switch(PixelRatio.get()) {
          case 1:
          return "mdpi";
          case 1.5:
          return "hdpi";
          case 2:
          return "xhdpi";
          case 3:
          return "xxhdpi";
          case 3.5:
          return "xxxhdpi";
        }

提交回复
热议问题