2

I have a ViewPager in my layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<android.support.v4.view.ViewPager
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:fitsSystemWindows="true"
    android:layout_height="match_parent" />

</RelativeLayout>

And I want all Fragments to be in fullscreen mode (the screen should be also under status bar). I also set in that Activity:

    getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
                    View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
    );

and tried several thinks but nothing work. In a different Activity this code works OK.

Do you know where the problem is?

Look at the screenshot. It's still below the Status bar: enter image description here

RedBassett
  • 3,469
  • 3
  • 32
  • 56
Pepa Zapletal
  • 2,879
  • 3
  • 39
  • 69

3 Answers3

0

For Fullscreen of Activity use fullscreen theme from manifest for that particular activity

<activity
   android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
 .../>

or you can also apply theme programmatically using Activity.setTheme()

If you want to include your app content as a background of statusbar, it is not possible, yes in newer versions you can customize the color of statusbar background.

Sufian
  • 6,405
  • 16
  • 66
  • 120
Arth Tilva
  • 2,496
  • 22
  • 40
0

put this in style.xml

<style name="Login" parent="AppTheme">
    <item name="android:windowFullscreen">true</item>
</style>

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimary</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowBackground">@color/white</item>
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
    <item name="android:textColorPrimary">@color/white</item>
    <item name="colorControlNormal">@color/white</item>
</style>

and this in manifest

 <activity
        android:name=".ui.activities.LoginActivity"
        android:theme="@style/Login"/>
Rajesh
  • 2,618
  • 19
  • 25
0

Remove android:fitsSystemWindows="true". That flag is used when you want to keep some components from displaying over the status and navigation bars.

Matt
  • 2,953
  • 3
  • 27
  • 46
Irina
  • 1