Hard Coding Notification/Title Bar Height - Bad Idea?

All your problems with Audio, Video and Images.

Hard Coding Notification/Title Bar Height - Bad Idea?

Postby Matt M » Fri Jun 25, 2010 6:52 pm

Hello,

I have a canvas/bitmap on which my app does it's painting (basically a rearranged version of FingerPaint from the API Demos). Every time width and height are required in methods such as Bitmap.createBitmap() or canvas.drawRect() I have width and height set as follows:

Display display = getWindowManager().getDefaultDisplay();
width = display.getWidth();
height = display.getHeight() - 50;

The reason for the "- 50" is to ignore the area of the Notification Bar / Title Bar at the top of the screen, so the only area that can be drawn upon is actually visible.

Now I know very little about pixels and screen density and how that all interact so my question is.. Is subtracting 50 to make up for the Notification/Title Bars a bad idea? Might it be -50 on the G1 emulator (and Motorola Droid as I've verified) but say -60 on the Nexus One? Or am I good and this is cross-device compatible?

Thank you!

Matt.
User avatar
Matt M
Developer
Developer
 
Posts: 30
Joined: Tue Apr 27, 2010 7:35 pm

Top

Re: Hard Coding Notification/Title Bar Height - Bad Idea?

Postby Matt M » Sat Jun 26, 2010 4:48 am

I've basically answered this question myself and decided yes, it is a bad idea (I feel I knew that all along just wanted to believe it wasn't because I couldn't find a solution).

Instead I get the view height in the onSizeChanged() method. No problems.

Matt.
User avatar
Matt M
Developer
Developer
 
Posts: 30
Joined: Tue Apr 27, 2010 7:35 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 25 guests