ANDROID FULL SCREEN . If you want to know about ANDROID FULL SCREEN , then this article is for you.

ANDROID FULL SCREEN


Understanding Android Full Screen Mode

Android Full Screen mode allows an app or activity to utilize the entire screen of the device, without any distractions from system elements like the status bar, navigation bar, or action bar. Full-screen mode is widely used in apps such as video players, games, photo viewers, and other media-rich applications where an immersive experience is crucial.

In this article, we'll explore what full-screen mode is, why it's important, and how to implement it in your Android app.


Why Use Full-Screen Mode?

Using full-screen mode offers several benefits:

  1. Immersive Experience: For gaming, video, and photo apps, it enhances the experience by eliminating UI elements that can distract from the content.
  2. Maximizing Screen Space: Full-screen mode maximizes the available screen real estate, allowing you to use all of the screen for displaying content.
  3. User Engagement: When users engage with apps like media players, full-screen mode improves their attention and focus on the content.
  4. Aesthetic Appeal: Full-screen mode can create a clean and polished look for your app by hiding unnecessary system bars and UI elements.

Types of Full-Screen Mode

There are different types of full-screen experiences in Android, depending on which system UI elements are hidden:

1. Status Bar Hidden

  • The status bar at the top of the screen, which shows the time, battery status, and notifications, can be hidden to provide a more immersive experience.

2. Navigation Bar Hidden

  • The navigation bar at the bottom, containing back, home, and recent buttons, can be hidden, leaving more space for the content.

3. ActionBar Hidden

  • The ActionBar, a common UI component in Android apps, can also be hidden to make more room for content. This is often done in fullscreen media apps or games.

4. Immersive Mode

  • Immersive mode hides both the status bar and navigation bar but allows them to temporarily show when the user interacts with the screen (e.g., swiping from the top or bottom). The bars will auto-hide again after a short time.

How to Enable Full-Screen Mode in Android

There are a few ways to make an Android activity or app full-screen, depending on the version of Android and your desired outcome.

1. Hiding Status Bar and Navigation Bar

To hide both the status bar and navigation bar, you can use the following code in your activity. This is commonly used for games and video apps.

Code Example:

import android.os.Bundle;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;

public class FullScreenActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_full_screen);

        // Hide the status bar and navigation bar
        getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_FULLSCREEN |               // Hide status bar
            View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |          // Hide navigation bar
            View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY           // Stick to full-screen
        );
    }
}

Explanation:

  • SYSTEM_UI_FLAG_FULLSCREEN: Hides the status bar.
  • SYSTEM_UI_FLAG_HIDE_NAVIGATION: Hides the navigation bar.
  • SYSTEM_UI_FLAG_IMMERSIVE_STICKY: Keeps the system bars hidden even when the user interacts with the screen (i.e., swiping from the edges). They will temporarily reappear and then hide again automatically.

2. Hiding ActionBar

If your app has an ActionBar (the toolbar at the top of the screen with the app name and action buttons), you may want to hide it for a true full-screen experience.

Code Example:

import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;

public class FullScreenActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_full_screen);

        // Hide the ActionBar
        if (getSupportActionBar() != null) {
            getSupportActionBar().hide();
        }

        // Hide the status bar and navigation bar
        getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_FULLSCREEN |
            View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
            View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
        );
    }
}

3. Enabling Full-Screen Mode for Entire App (Manifest Method)

To make an activity full-screen by default, you can define a custom theme in your styles.xml file and apply it in your AndroidManifest.xml.

Steps:

  1. Define a Full-Screen Theme in styles.xml:
<resources>
    <style name="AppTheme.FullScreen" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowFullscreen">true</item>
        <item name="android:windowNoTitle">true</item>
    </style>
</resources>
  1. Apply the Full-Screen Theme in AndroidManifest.xml:
<activity
    android:name=".FullScreenActivity"
    android:theme="@style/AppTheme.FullScreen">
</activity>

This will automatically apply the full-screen settings to the activity without the need to write code for hiding UI elements.


4. Handling Full-Screen Mode on Orientation Changes

Sometimes, when users change the orientation (e.g., rotating the device from portrait to landscape), full-screen mode may reset. To handle this, you can reapply full-screen mode in the onResume() method to ensure the experience remains seamless.

Code Example for Persistent Full-Screen Mode:

import android.os.Bundle;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;

public class FullScreenActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_full_screen);

        // Set the full-screen mode
        setFullScreen();
    }

    @Override
    protected void onResume() {
        super.onResume();
        // Reapply full-screen mode after orientation change
        setFullScreen();
    }

    private void setFullScreen() {
        // Hide status bar and navigation bar
        getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_FULLSCREEN |
            View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
            View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
        );
        
        // Optionally, hide ActionBar
        if (getSupportActionBar() != null) {
            getSupportActionBar().hide();
        }
    }
}

By calling setFullScreen() in both the onCreate() and onResume() methods, you ensure the activity remains full-screen even if the device is rotated.


5. Immersive Mode for a Better Experience

In Immersive Mode, the system UI is hidden until the user swipes from the edge of the screen. This provides a more dynamic experience because the system UI can temporarily reappear when needed.

Code Example for Immersive Mode:

import android.os.Bundle;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;

public class FullScreenActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_full_screen);

        // Set immersive full-screen mode
        getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_FULLSCREEN |                    // Hide status bar
            View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |               // Hide navigation bar
            View.SYSTEM_UI_FLAG_IMMERSIVE |                     // Enable immersive mode
            View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY                // Sticky immersive mode
        );
    }
}

In immersive mode, the system UI hides by default but temporarily reappears when the user interacts with the screen. After a brief moment, the system UI auto-hides again.


Conclusion

Implementing full-screen mode in Android apps allows users to have a more engaging and immersive experience. Whether you’re creating a media app, a game, or a gallery app, full-screen mode can enhance user interaction by maximizing available screen space and eliminating distractions. The methods to enable full-screen mode are straightforward, whether through the system UI visibility flags, manifest themes, or immersive modes.

By using these techniques, you can provide a cleaner, more polished experience for your app users. Ensure that full-screen settings are applied consistently, and handle things like orientation changes to maintain a smooth, uninterrupted experience.