2

I have the next problem - when I build my react-native app into apk file, and then install app into the device, I get wrong data display(something like under a magnifying glass). After a few hours of working, I decide to do alert from demension(of course I did rebuild of apk ) my device height and width. And here is the question! - On my Galaxy S6 with resolution 2000+ x 1500+ I have got 640 x 480! Someone can help with this?

P.S Also I tried to find dependence on PixelRatio

import  Dimensions  from    'Dimensions';

let {width , height }   =   Dimensions.get('window');

componentDidMount() {
 alert( 'PIXEL_RATIO '+PixelRatio.get() + `WIDTH ${width} HEIGHT ${height}`)
 }
Gotikes
  • 61
  • 2
  • 3
  • Here is addition info : I had run Htc Evo from Genymotion, and get next results : 720x1280 dpi 160 (PixelRatio - 1.0) works great! Dimension return 720 and 1280 , 720x1280 dpi 240 (PixelRatio - 1.5) works wrong! Dimension return 480 and ~850 , 720x1280 dpi 320 (PixelRatio - 2.0) works wrong! Dimension return 480 x 640 – Gotikes Jul 06 '16 at 08:04
  • This´ll probably help getting your screen size, if that´s where your error comes from: http://stackoverflow.com/questions/1016896/get-screen-dimensions-in-pixels – Der Oromis Jul 06 '16 at 07:47
  • Thank, but it is about Android Sdk. But I am using ReactNative – Gotikes Jul 06 '16 at 07:55

1 Answers1

6

I also had the same problem. The get function of the Dimension class returning a scaled size of the window. I can get the correct screen size like these:

window = Dimensions.get('window');
width = window.width * window.scale;
height = window.height * window.scale;
Gergő Kajtár
  • 454
  • 4
  • 12