Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to know density of device?

Tags:

android

As we can get the resolution in android, but how can we know the density of the device (screen) ?

thanks

like image 647
Hitendra Avatar asked Jan 22 '11 04:01

Hitendra


1 Answers

Execute the following code:

float scale = getApplicationContext().getResources().getDisplayMetrics().density;

and check the value of scale:

  • 0.75 means low density
  • 1.0 means standard (medium) density
  • 1.5 means high (large) density
  • 2.0 means extra high density
  • 3.0 means extra extra high density
  • 4.0 means extra extra extra high density

See the documentation for more info.

like image 100
chikka.anddev Avatar answered Nov 08 '22 12:11

chikka.anddev