Home > Software engineering >  Splash Activity in Android not setting as FULL SCREEN ACTIVITY - Samsung M51
Splash Activity in Android not setting as FULL SCREEN ACTIVITY - Samsung M51

Time:09-17

To make the Full-Screen Activity, So far I have tried it as below :

requestWindowFeature(Window.FEATURE_NO_TITLE)

before setContentView() method in Activity.

Also Tried adding below lines :

 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN)

But it not worked. Then, I have moved to manifest and Tried as below :

android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"

<activity
        android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"
        android:name="SplashActivity"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

and the stype I have tried above is as below :

 <style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
</style>

And Yes, In my layout the Root tag is as below :

<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="@drawable/bg_layout_screen">

means using android:fitsSystemWindows="true"

Now, the issue is It's not visible as full-screen activity. The issue screenshot is as below :

[![enter image description here][1]][1][![enter image description here][2]][2]

But Still, the issue is as below Image.

First Image : [1]: https://i.stack.imgur.com/fbJ2l.jpg

Second Image : [2]: https://i.stack.imgur.com/ZTpgw.jpg

Black is while adding this line in manifest :

android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"

Please guide. What might be the issue? Thanks.

CodePudding user response:

As per your first image you have to just change the color of your status bar to transperent. To do it please refer below post

Android Completely transparent Status Bar?

Hope this post helpful to you :)

CodePudding user response:

You can use onWindowFocusChanged() and View decorView = getWindow().getDecorView(); then set SystemUiVisibility.

Example:

//set full screen
@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus) {
        hideSystemUI();
    }
}

private void hideSystemUI() {
    View decorView = getWindow().getDecorView();
    decorView.setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                    // content doesn't resize when the system bars hide and show.
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    // Hide the nav bar and status bar
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_FULLSCREEN
    );
}
  • Related