Android: Get the screen resolution / pixels as integer values

Posted by poeschlorn on Stack Overflow See other posts from Stack Overflow or by poeschlorn
Published on 2010-05-25T07:03:26Z Indexed on 2010/05/25 7:21 UTC
Read the original article Hit count: 190

Filed under:
|

Hi guys, this is a really simple question on which I've found no answer :/ How can I quickly access the screen resolution (width, height) as integer values?

I've tried this one, but it always shows zero on my emulator:

DisplayMetrics dm = new DisplayMetrics();
int width = dm.widthPixels / 2;

In my case I want to dynamically create a table with tableRows, each containing two cols. This cols all shall fill half of the screen in width.

Can someone give me a hint?

© Stack Overflow or respective owner

Related posts about android

Related posts about resolution