BottomSheetDialogFragment bottom navigation color
See original GitHub issueI have tried to apply a custom color to the bottom navigation bar but failed. I tried this:
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowLightNavigationBar">true</item>
<item name="android:navigationBarColor">@color/white</item>
<item name="android:windowTranslucentNavigation">false</item>
It works for usual DialogFragment but not for the BottomSheetDialogFragment.
I tried this also:
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog
dialog.setOnShowListener { dialogInterface ->
val d = dialogInterface as BottomSheetDialog
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
d.window?.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION)
d.window?.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
d.window?.navigationBarColor = ContextCompat.getColor(requireContext(), R.color.white)
}
}
return dialog
}
How can I change the nagivation bar color to custom? Right now it is always transparent.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:20
- Comments:13
Top Results From Across the Web
Prevent BottomSheetDialogFragment covering navigation bar
Nothing changes: neither the navigation bar color nor the style of the bottom sheet widget. Any hints of what might I be doing...
Read more >Show BottomSheetDialogFragment changes status bar color ...
I think the BottomSheetDialogFragment should not change the status bar color to black as this somehow effects the style of the app. I...
Read more >Bottom Sheet Above Bottom Navigation | by Narayan Panthi
Bottom Sheet Above Bottom Navigation. Show BottomSheetDialog above the BottomNavigation in android. ... android:background="@android:color/transparent">
Read more >Android bottom sheet behind navigation bar
Android bottom sheet behind navigation bar · Transparent background for BottomSheetDialogFragment · Bottom sheet background color · Custom bottom sheet dialog ...
Read more >BottomSheetDialogFragment - Android Developers
This is a version of DialogFragment that shows a bottom sheet using BottomSheetDialog instead of a floating dialog. Summary. Inherited constants.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
My solution for this is by having my own bottom sheet style and applying it by overriding the
getTheme()
method:I’m yet to try making the navbar transparent and making the actual bottom sheet draws under the navbar, but that one is working for now.
There’s no need to override an entire theme, or change any of your Java/Kotlin code. Just set the appropriate theme overlay in your app theme: