I'm using this:
int wi=getWindowManager().getDefaultDisplay().getWidth();
to get the screen size in pixels. Is there a way to get the screen size in dpi
???
I'm doing this to select different layouts base on the screen size.
Is there a way to get the escreen size in dpi???
DisplayMetrics
can tell you the screen size in pixels, plus the screen density. From there, you can calculate the screen size in dp
.
I'm doing this to select different layouts base on the screen size.
This is automatically handled for you by the resource framework, if you put your layouts in the proper directories (e.g., res/layout-large/
, res/layout-sw600dp/
).