yamete senpai
yamete senpai

Reputation: 21

How to make screen go fullscreen android

i have used

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

added this to manifest.xml

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

and added

    <item name="android:windowNoTitle">true</item>
    <item name="android:windowFullscreen">true</item>

to my theme still i get this result https://i.sstatic.net/YmPFK.jpg

Upvotes: 0

Views: 74

Answers (3)

Ji Sungbin
Ji Sungbin

Reputation: 1301

Try this way.

Theme:

    <style name="Theme.SpakChat.FullScreen" parent="Theme.SpakChat">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowTranslucentStatus">true</item>
        <item name="android:windowTranslucentNavigation">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">@android:color/transparent</item>
        <item name="android:windowFullscreen">true</item>
    </style>

Your activity xml root view:

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"> <---- added

Your activity:

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        // added
        window.setFlags(
            WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
            WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
        )

        setContentView(binding.root)
....

Result:

Upvotes: 1

Ole Pannier
Ole Pannier

Reputation: 3673

In your AndroidManifest.xml you need to use AppCompat Theme with extension .Fullscreen:

<manifest ... >
    <application android:theme="@style/Theme.AppCompat.Fullscreen" ... >
    </application>
</manifest>

If you want to apply this only to some Activities then do it inside <activity instead of <application.

Upvotes: 0

MadMax
MadMax

Reputation: 101

I use normally this function to make my activities fullscreen. You can add it in a Utils folder and use it in any activity you want.

 public static void setFullScreen(Activity activity){
        View decor_View = activity.getWindow().getDecorView();

        int ui_Options = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

        decor_View.setSystemUiVisibility(ui_Options);
    }

Upvotes: 0

Related Questions