I have a device with resolution 800*480.
I create “Hello word” application. Then I get DisplayMetrics in onCreate of MainActivity.
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
Log.d("Resolution", "resolution: " + metrics.widthPixels + " x " + metrics.heightPixels);
In DisplayMetrics there are 533*320 pixels. Why?
How can I make application for resolution 800*480 pixels.
It’s because you are reading
device independent pixelsnotreal pixels. Thesedipare equal tomdpiresolution. So despite real screen size, you should check what density it is (mdpiorhdpiorxdpi) and then put your hi-res assets in-hdpisuffixed folder (i.e.drawable-hdpiorlayout-hdpi). Usually you set your layout indp(so one layout XML file per activity usually suffices, and you should put them as usual in genericres/layoutfolder). and then put hi res drawables to make app look nicer onhdpideviceSee this article for pixel-size and density relations…