Notification panel in libgdx

I want to create a game using the Libgdx engine. It creates a default FULLSCREEN game without a notification bar.
Can I create an ad panel with ?

+4
source share
3 answers

In 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 is cfg.hideStatusBar = false;

Hope that helps

EDIT

Good, so I worked a little on this topic, and it turns out that it is quite easy. I looked at the libgdx wiki page to add admob ads . Follow all steps except adding ads!

The following is a modified code for setting up a non-full-screen Android application:

 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 easily add all the layout options you want by googleing "RelativeLayout layoutParams". Hope this helps. Please mark the question as an answer.

+6
source

Since I am not yet allowed to comment, I will answer. Basically everything that LiamJPeters says, except that you recently created a project from scratch with one of the newbies in the libgdx style, then there will also be "res / values ​​/ styles.xml" referenced in the expression .

I had to change two settings there (in addition to everything written by LiamJPeters) in order to eventually display the notification panel 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> 
+6
source

I ran into confusion here and couldn't get it to work for a while on Android Lollipop. I had to actually combine all the code given here in the answers to show the status bar of the application.

So, the final working code for me is as follows:

Part of Java is combining the relative layout and configuration of hideStatusBar (thanks to LiamJPeters)

 protected void onCreate (Bundle savedInstanceState) { super.onCreate(savedInstanceState); AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); config.hideStatusBar = false; RelativeLayout layout = new RelativeLayout(this); layout.addView(initializeForView(new MyAndroidApp(), config)); setContentView(layout); } 

And styles.xml part - windowFullscreen to false (thanks Bernrd K.)

 <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">true</item> <item name="android:windowContentOverlay">@null</item> <item name="android:windowFullscreen">false</item> </style> </resources> 

Note: windowNoTitle has nothing to do with the status bar. Depends on what you need, but the xml above only shows the status bar, no headers.

0
source

All Articles