Screen dimensions as pixels | Get screen dimensions as pixels in Android

Published by inkskull on

Checkout Screen dimensions as pixels | Get screen dimensions as pixels in Android

You can pragmatically get display size.

Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;

If you’re not in an Activity you can get the default Display via WINDOW_SERVICE using the below code

WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Categories: Android

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Social Media Auto Publish Powered By : XYZScripts.com