Tuesday, December 7, 2010

Windows Phone 7 Quick Tip #24 – Hide the Status Bar in your XNA Application

To hide the status bar:


Simply set the property IsFullScreen on the GraphicsDeviceManager instance to true:

public Game1()
    graphics = new GraphicsDeviceManager(this);
    graphics.IsFullScreen = true;

Not only will this let your application take advantage of the full height of the device and not display the status bar it also will fill the width of your device to maintain the proper aspect ratio.  Let me explain.  If you specify your PreferredBackBuffer Width and Height to be 480x800 and not hide the status bar, there will be a margin on both the right and left of your screen.  Your screen will maintain your aspect ratio of 3/5.  This means since the height of your screen is not actually 800 pixels (because the status bar takes up a portion of the top of the screen), to maintain the aspect ratio, your width won’t be 480. 

This is especially obvious when you use Snippet in Windows Mode to capture a screen shot of your application, you will see a black border across the top and sides of your screen.  Setting graphics.IsFullScreen = true will allow your applications height to be 800 and thus the width will be 480 maintaining the correct aspect ratio and making the full use of the real-estate on the device.


No comments:

Post a Comment