Priya Sasane
Priya Sasane

Reputation: 103

Hide bottom navigation bar - shows white strip at bottom

I need to hide Bottom Navigation Bar. I used these flag as :

getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_IMMERSIVE
                        | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_FULLSCREEN
But blank white strip appears at bottom of device.
How to remove that?

I have flow like this MainActivity - > HomeFragment - > InventoryFragment. In InventoryFragment i want to remove navigation bar.

Upvotes: 0

Views: 2007

Answers (1)

Anurag Singh
Anurag Singh

Reputation: 6200

Replace View.SYSTEM_UI_FLAG_IMMERSIVE with View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY

AppCompatActivity code:

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.your_layout);
mDecorView = getWindow().getDecorView();

int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN |
    View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
    View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
    View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
mDecorView.setSystemUiVisibility(uiOptions);
}

Xml Layout file:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFE744"
tools:context="....">

APP theme:

<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@color/custom_black</item>
</style>

AppCompatActivity theme is same as application theme

Upvotes: 1

Related Questions