1
\$\begingroup\$

I am using Monogame to create a small Android game. I am trying to draw a sprite to the Android screen but it seems to have a padding of some pixels. The same game works fine on desktop.

How can I remove the padding? The graphic itself has no borders etc; the problem is also reproducible with any other sprite.

I have created a new project in VS2019 with the Monogame templates for VS2017 and tried to reproduce this behavior in a new project.

It seems that the problem has something to do with the notch of my emulator. In an emulator without a notch the problem seems to be non existent. I found this thread on the Monogame community but it hasn't got any answers.

My source code looks in its simplest form now as follows:

    private Texture2D _texture;

    protected override void LoadContent()
    {
        spriteBatch = new SpriteBatch(GraphicsDevice);
        _texture = Content.Load<Texture2D>("BasicTV");
    }

    protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.CornflowerBlue);
        spriteBatch.Begin();

        spriteBatch.Draw(_texture, Vector2.Zero, Color.White);

        spriteBatch.End();
        base.Draw(gameTime);
    }

The result of this code is this:

enter image description here

The Game is compiled for Android 8.1 and I use the Monogame framework 3.7.1.

\$\endgroup\$
2
  • \$\begingroup\$ What size is the texture? If it's not a power-of-2, have you checked if your Android GPU supports non-power-of-2 textures? Likewise, there may be a requirement for width to be a multiple of 4. \$\endgroup\$ Oct 6, 2019 at 17:29
  • \$\begingroup\$ @MaximusMinimus It is now height:1024 width:2048. The behavior stays the same. In Landscape mode the padding is much smaller but still observable. In the real app I have a transformation matrix which makes the small padding to appear bigger and it is on the top and the bottom, which leads me to think that if i had a big enough picture you could observe the same problem in my little demo \$\endgroup\$
    – Bongo
    Oct 6, 2019 at 18:06

1 Answer 1

2
\$\begingroup\$

After trying several things it seems that it is a problem with version 3.7.1 of Monogame. I switched to Version 3.6 and the padding is gone. I will update this answer/question if I find the reason why 3.6 behaves differently then 3.7.1

Edit: I switched to version 3.8 and the problem seemed to still exist. But it seems that with this little snippet the problem could be fixed (found here) .

    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
        //...
        HideSystemUI();
        g.Run();
    }
    private void HideSystemUI()
    {
        SystemUiFlags flags = SystemUiFlags.HideNavigation | SystemUiFlags.Fullscreen | SystemUiFlags.ImmersiveSticky;
        this.Window.DecorView.SystemUiVisibility = (StatusBarVisibility)flags;
    }
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .