0

In Android documentation says, that I can use alternate resources for devices that (for example) has minimum available width in dp units at which the resources should be used—defined by the value.

So by creating "w720dp" folder, creates resources for particular tablets. I would like to know how programatically calculate how much width does particular device have.

Thanks in advance!

rootpanthera
  • 2,731
  • 10
  • 33
  • 65
  • 1
    this may help (http://stackoverflow.com/questions/3166501/getting-the-screen-density-programmatically-in-android) tells you the dpi and the width in pixels. – Todoy Nov 25 '13 at 17:18

1 Answers1

0

You can get the pixels

DisplayMetrics metrics = context.getResources().getDisplayMetrics();
int width = metrics.widthPixels;
int height = metrics.heightPixels;

and then divide them by the pixel density

float density  = metrics.density;
andrei
  • 2,934
  • 2
  • 23
  • 36