PixelRatio.get()
获得屏幕的dpi(像素密度),其中:
- PixelRatio.get() === 1
mdpi Android devices (160 dpi) - PixelRatio.get() === 1.5
hdpi Android devices (240 dpi) - PixelRatio.get() === 2
iPhone 4, 4S
iPhone 5, 5c, 5s
iPhone 6
xhdpi Android devices (320 dpi) - PixelRatio.get() === 3
iPhone 6 plus
xxhdpi Android devices (480 dpi) - PixelRatio.get() === 3.5
Nexus 6
将dp转成px
getPixelSizeForLayoutSize(layoutSize:number)
static 静态方法, 进行把dp转换成像素px,该会返回一个整形的数值
网友评论