# Android: SDL\_CreateWindow always aligns the game to the left of the device screen

**URL:** <https://discourse.libsdl.org/t/android-sdl-createwindow-always-aligns-the-game-to-the-left-of-the-device-screen/19448>\
**Category:** SDL Development\
**Created:** [March 15, 2013, 6:43am UTC](https://discourse.libsdl.org/t/android-sdl-createwindow-always-aligns-the-game-to-the-left-of-the-device-screen/19448 "2013-03-15T06:43:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Giorgos\_Sarris](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/g/f0a364/32.png) [@Giorgos\_Sarris](https://discourse.libsdl.org/u/Giorgos_Sarris)\
**Post date:** [March 15, 2013, 6:43am UTC](https://discourse.libsdl.org/t/android-sdl-createwindow-always-aligns-the-game-to-the-left-of-the-device-screen/19448/1 "2013-03-15T06:43:58Z")

</div>

Hi there,

I have SDL HG for android, a very recent build.  
I noticed that:

SDL\_CreateWindow(GAME\_TITLE, SDL\_WINDOWPOS\_CENTERED,  
SDL\_WINDOWPOS\_CENTERED, SCREEN\_WIDTH, SCREEN\_HEIGHT, SDL\_WINDOW\_OPENGL |  
SDL\_WINDOW\_SHOWN | SDL\_WINDOW\_FULLSCREEN);

If the screen set with “SCREEN\_WIDTH” and “SCREEN\_HEIGHT” is smaller than  
the device screen, SDL\_CreateWindow always puts the game screen aligned to  
the left. It should be aligned to the middle. This is a problem since most  
games aim from 4/3 format to 16/9 while most device screens are in that  
format but since the android bar is always on the remaining resolution  
aspect ratio is sometimes wider and thus the game has to be letterboxed a  
little.

Hoe can I patch it? Or fix this?

Thanks  
Giorgos

---

<div class="post-metadata">

**Author:** ![Gabriele\_Greco](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/g/8edcca/32.png) [@Gabriele\_Greco](https://discourse.libsdl.org/u/Gabriele_Greco)\
**Post date:** [March 15, 2013, 1:48pm UTC](https://discourse.libsdl.org/t/android-sdl-createwindow-always-aligns-the-game-to-the-left-of-the-device-screen/19448/2 "2013-03-15T13:48:58Z")

</div>

> If the screen set with “SCREEN\_WIDTH” and “SCREEN\_HEIGHT” is smaller than  
> the device screen, SDL\_CreateWindow always puts the game screen aligned to  
> the left. It should be aligned to the middle. This is a problem since most  
> games aim from 4/3 format to 16/9 while most device screens are in that  
> format but since the android bar is always on the remaining resolution  
> aspect ratio is sometimes wider and thus the game has to be letterboxed a  
> little.
> 
> Hoe can I patch it? Or fix this

SDL\_WINDOWPOS\_CENTERED is for… windows.

You are using a fullscreen display, so it does not apply, you can anyway  
achieve what you need rendering to a surface (with SDL\_SetRenderTarget for  
instance) and then blitting your surface to the desired position/aspect  
ratio.–  
Bye,  
Gabry
