Hey there guys! :)

I'm quite a newbie to Android programming, and I need to get the dimensions of the screen, that is the visible area of the screen. I know I can just set the layout of the controls in the .xml file, but I explicitly need to do it through code.
I have found out about the WindowManager.CurrentDisplay.Height and Width respectively, but it just doesn't do the trick: the height I get is greater than the actual height of the visible screen area.

I am coding in Vusual Studio 2010, using the Mono Android plugin. If anyone could give me at least a lead or an idea, I would be most appreciative! :)

Thank you, and have a nice day! xD

Recommended Answers

All 2 Replies

Try

Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();

PS: Better to move something like Eclipse or IntelliJ that have better Android support

Thank you for the answer! :)

I tried implementing your suggestion, but unfortunately I cannot cast from the source to the destination type, for some mysterious reason...

Moreover, I'd really love to use another IDE for developing Android apps, but it doesn't depend on my preferences, so there's nothing I can do...

Anyway, thanks again! I'll try something else, probably... :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.