Last Update - 31 Oct 2018

Getting the screen density programmatically in android

Getting the screen density programmatically in android

You can get info on the display from the DisplayMetrics struct:

DisplayMetrics metrics = getResources().getDisplayMetrics();

This will give you:

0.75 - ldpi

1.0 - mdpi

1.5 - hdpi

2.0 - xhdpi

3.0 - xxhdpi

4.0 - xxxhdpi

Did you find this page helpful? X