Blog Details

img
Data Science

How can I get my Android screen width and height

Spoke Right / 17 Nov, 2023

The size of a desktop computer monitor is determined by physically measuring the screen. Using a measuring tape, start at the top-left corner and pull it diagonally to the bottom-right corner. Be sure to only measure the screen; do not include the bezel (the plastic edge) around the screen.

DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
float displayHeight = displayMetrics.heightPixels / displayMetrics.density;
float displayWidth = displayMetrics.widthPixels / displayMetrics.density;
Log.d("Display Height", displayHeight +"");
Log.d("Display Width", displayWidth +"");

0 comments

Warning: PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20210902/imagick.so (/usr/local/lib/php/extensions/no-debug-non-zts-20210902/imagick.so: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20210902/imagick.so.so (/usr/local/lib/php/extensions/no-debug-non-zts-20210902/imagick.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0