Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

notification bar in libgdx game

Tags:

android

libgdx

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?

like image 505
10 revs Avatar asked Apr 12 '13 17:04

10 revs


2 Answers

Since I am not (yet) allowed to comment I will make it an answer. Basically everything said by LiamJPeters helps, except you have set up the project recently from scratch with one of the newer libgdx nightlies, then there will also be a "res/values/styles.xml" which is referenced in the manifest.

I had to change two settings there (in addition to everything written by LiamJPeters) to make it finally show the notification bar and the window title:

<resources>
    <style name="GdxTheme" parent="android:Theme">
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:colorBackgroundCacheHint">@null</item>
        <item name="android:windowAnimationStyle">@android:style/Animation</item>
        <item name="android:windowNoTitle">false</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowFullscreen">false</item>
    </style>
</resources>
like image 116
Bernd K. Avatar answered Nov 15 '22 07:11

Bernd K.


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.

like image 44
LiamJPeters Avatar answered Nov 15 '22 07:11

LiamJPeters