Search code examples
androidlibgdx

notification bar in libgdx game


I want to create game using Libgdx engine. It's create by default FULLSCREEN game without notification bar.
Can i create game with notification bar?


Solution

  • In the Android starter:

    public class MainActivity extends AndroidApplication {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
            cfg.hideStatusBar = false;
            initialize(new MainClass(), cfg);
        }
    }
    

    The important line here being cfg.hideStatusBar = false;

    Hope that helps

    EDIT

    Ok so I've done a bit of research on the subject and it turns out it's pretty easy. I looked on the libgdx wiki page for adding admob ads. Follow all the steps except adding the ads!

    Below is modified code for setting up a non-fullscreen android app:

    public class MainActivity extends AndroidApplication {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            RelativeLayout layout = new RelativeLayout(this);
            layout.addView(initializeForView(new MainClass(), false));
            setContentView(layout);
        }
    }
    

    You can add all the layout parameters you want very easily by googleing "RelativeLayout layoutParams". Hope this helps. Please mark the question as answered.