Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out the device screen resolution and density to set same UI display on the emulator and device?

Tags:

android

I need to set same UI in both device and emulator (In my application the UI changing in emulator and device)for that i need to know the screen resolution and density of the device . I don't know how to find out that .Let me know how to find out that in device.

Thanks,

Lakshmanan

like image 458
Lakshmanan Avatar asked Jan 22 '23 04:01

Lakshmanan


1 Answers

    DisplayMetrics displaymetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    int screenHeight = displaymetrics.heightPixels;
    int screenWidth = displaymetrics.widthPixels;
like image 166
rjdthegreat Avatar answered Jan 30 '23 01:01

rjdthegreat