Kewal Shah
Kewal Shah

Reputation: 1260

How to remove the black bar appearing at the bottom?

I am new to Android Development. I want my app to support the screen size of my device i.e. 1080 x 2160 pixels. Currently there is a black bottom bar that is displayed in place of where the navigation buttons would have been.

enter image description here

Please note that I do not want Full Screen Mode. I have disabled the button navigation on my device. It is only for this app that that the bottom black rectangle is showing. I just want my app to support the gesture navigation system of my device instead of buttons.How do I make the bottom bar go away using Java (Android Studio) so that my app utilizes that space?

Upvotes: 4

Views: 3811

Answers (5)

Mahesh Naik
Mahesh Naik

Reputation: 71

I had the same issue, updated manifest file with this or remove if you have one.

before

<meta-data
    android:name="android.max_aspect"
    android:value="2.1" />

after

<meta-data
    android:name="android.max_aspect"
    android:value="2.4" />

working for me now.

Upvotes: 1

Kirguduck
Kirguduck

Reputation: 796

question is old but I faced the same issue and didnot find the solution on SO.
this problem occurs for long screens

We recommend that you design your app to support aspect ratios of 2.1 or higher. For this, you would add the following to the "application" element in your Manifest file:

<meta-data android:name="android.max_aspect" android:value="2.1" />

from here

Upvotes: 3

user10842245
user10842245

Reputation:

Try to add this code

@Override
protected void onCreate(Bundle savedInstanceState) {
    ...
    hideSystemUI(this, 1000);
}

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus) {
        // Hide bar after 1 second
        hideSystemUI(this, 1000);
    }
}

public static void hideSystemUI(@NonNull final Activity activity, final int delayMs) {
    View decorView = activity.getWindow().getDecorView();
    int uiState = View.SYSTEM_UI_FLAG_IMMERSIVE
            | 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;
    final Handler handler = new Handler();
    decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
        @Override
        public void onSystemUiVisibilityChange(int visibility) {
            if (visibility == View.VISIBLE) {
                Runnable runnable = new Runnable() {
                    @Override
                    public void run() {
                        hideSystemUI(activity, 1000);
                    }
                };
                handler.postDelayed(runnable, delayMs);
            }
        }
    });
    decorView.setSystemUiVisibility(uiState);
}

WARNING

If you have two activities, add this before changing

View decorView = getWindow().getDecorView();
decorView.setOnSystemUiVisibilityChangeListener(null);

Upvotes: 0

Sejpal Pavan
Sejpal Pavan

Reputation: 140

You can try this

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus) {
        getWindow().getDecorView().setSystemUiVisibility(
                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);
    }
}

Upvotes: 0

Vasudev Vyas
Vasudev Vyas

Reputation: 742

Hi please Try below code

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

Upvotes: 0

Related Questions