Home > database >  Why the color of System BottomNavigation changes to black when i open bottomsheet?
Why the color of System BottomNavigation changes to black when i open bottomsheet?

Time:07-01

I have set the background color of system bottomNavigation using:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
     getWindow().setNavigationBarColor(getResources().getColor(R.color.navcolor));
}

Which is working properly !!!

But the problem is when i open a custom bottomsheet, the background color of bottomNavigation gets changed to black.

Code to show bottomsheet:

BottomSheetDialog dialog = new BottomSheetDialog(MainActivity.this);
dialog.setContentView(R.layout.sortfilterbottomsheet);
dialog.setCanceledOnTouchOutside(true);
dialog.show();

BottomNavigation when bottomsheet is closed: enter image description here

BottomNavigation when bottomsheet is opened: enter image description here

Can somebody help ?

CodePudding user response:

So finally I got my answer.

We need to write:

<item name="android:navigationBarColor" tools:targetApi="21">@color/navcolor</item>

in themes.xml file

It will change the background color of system bottom naivgation.

  • Related