1

Even when I use GraphicsDevice.ToggleFullScreen() or GraphicsDevice.IsFullScreen = true; followed by GraphicsDevice.ApplyChanges() as described in this post, I still seem to have this border on both edges of the screen, shown in classic CornflowerBlue for contrast in this screenshot. The background image is anchored at 0,0 with width and height set to the dimensions of the screen. The "borders" seem to be about 10 or 20px from what I can guess, and not at the top or bottom, only at the left and right edges. I can't understand where this is coming from.

enter image description here

Jason
  • 562
  • 2
  • 5
  • 13
  • What are you basing "the dimensions of the screen" on? –  Nov 18 '21 at 03:00
  • 1
    Did you define the resolution of your game? – Silver Nov 18 '21 at 03:31
  • @Strom Dimensions of the screen I've obtained from Window.ClientBounds.Width & Height at 1080 x 2160 respectively. I get similar results from (deprecated) Activity.WindowManager.DefaultDisplay.Width & Height, although the latter seems to account for the nav bar whereas the former doesn't. Incidentally, the documentation for my device confirms 1080 x 2160, but obviously I want to detect the bounds of whatever device it's running on. – Jason Nov 18 '21 at 19:32
  • @Silver No, I don't believe I have specified the resolution anywhere. I'm just trying to operate within the bounds of the display. Do you mean pixel density? Where can I read/learn more about this? – Jason Nov 18 '21 at 19:33
  • @Silver Okay, your comment got me thinking about the problem differently. Once I set the PreferredBackBufferWidth & Height to match the dimensions of the device bounds, the bars/borders are gone. If you repost your comment as an answer, I'll mark it as the accepted answer. THANK YOU. – Jason Nov 18 '21 at 19:43

1 Answers1

0

If you want your game to be at full screen of every device:

#if ANDROID
            graphics.IsFullScreen = true;                
            graphics.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            graphics.SupportedOrientations = DisplayOrientation.Portrait;//if your game does NOT support for anything else but portrait mode
            graphics.ApplyChanges();
#endif

However, in this case, you need to be careful because the ratio of devices are different, some are 16:9, some are 4:3, etc. If you need your game to be adapt to all of them, you better adjust the sizes of your game objects to be changeable or set them to be proportional.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Silver
  • 482
  • 2
  • 6