Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the density of a screen?

Tags:

android

screen

How to get density of a screen? I have tried with the following code. I got density as 1.0. I changed my emulator TO HVGA, QVGA and WVGA still I am getting the same result.

int density = getResources().getDisplayMetrics().density;

How to get actual density of my emulator screen.

like image 301
Sunil Kumar Sahoo Avatar asked Jun 24 '11 10:06

Sunil Kumar Sahoo


Video Answer


1 Answers

Check with this code,

DisplayMetrics metrics = new DisplayMetrics();    
getWindowManager().getDefaultDisplay().getMetrics(metrics);    
int screenDensity = metrics.densityDpi;    
like image 112
sat Avatar answered Sep 30 '22 08:09

sat