Search code examples
androidthemesandroid-fullscreen

Full Screen Activity for App in Android Studio


I came across this app (I attach a screen), where you can see that the background of the app also seems to extend into the bar where there is the time, the network status, etc etc, I wanted to try to replicate it but I don't get much enter image description here

I tried with this theme

<style name="AppFullScreenTheme" parent="Theme.AppCompat.Light">
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowActionBar">false</item>
        <item name="android:windowFullscreen">true</item>
        <item name="android:actionBarStyle">@style/MyActionBar</item>
        <item name="android:windowContentOverlay">@null</item>
    </style>

    <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
        <item name="android:background">@color/ice</item>
    </style>

But what I get is this: enter image description here

Could it be a custom layout?


Solution

  • You can achieve it by declaring a flag to window in onCreate method:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 
         getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
                        WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        }
    ...
    }
    

    also in app theme:

    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
            <!-- Customize your theme here. -->
            <item name="android:windowNoTitle">true</item>
            <item name="android:windowActionBar">false</item>
            <item name="android:windowFullscreen">false</item>
            <item name="android:windowContentOverlay">@null</item>
    </style>
    

    You should assign "android:windowFullscreen" to false to show the status bar.

    Hope this fix your issue.