question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BottomSheetDialog] android:colorBackground stopped working with version 1.2.0

See original GitHub issue

Description:

Starting with version 1.2.0 the android:colorBackground attribute is ignored and the bottom sheet dialog always has a white background set.

Expected behavior:

android:colorBackground should set the background color of the sheet as with version 1.1.0.

Source code:

<style name="ShoppingList.BottomSheetDialog" parent="Theme.MaterialComponents.Light.BottomSheetDialog">
    <item name="android:colorBackground">@android:color/transparent</item> <!-- has no effect -->
    <item name="android:backgroundDimAmount">0.3</item>
</style>

Android API version: 29

Material Library version: 1.2.0

Device: Google Pixel

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

16reactions
gabrielemariotticommented, Aug 26, 2020

You can use something like:

val dialog = BottomSheetDialog(
    context,
    R.style.ThemeOverlay_App_BottomSheetDialog
)

with:

    <style name="ThemeOverlay.App.BottomSheetDialog" parent="@style/ThemeOverlay.MaterialComponents.BottomSheetDialog">
        <item name="bottomSheetStyle">@style/ShoppingList.BottomSheetDialog</item>
    </style>

    <style name="ShoppingList.BottomSheetDialog" parent="Widget.MaterialComponents.BottomSheet.Modal">
        <item name="backgroundTint">@color/....</item>
    </style>
Schermata 2020-08-26 alle 12 21 06
2reactions
svenjacobscommented, Oct 29, 2020

I was finally able to fix this by also applying an elevation to the style, which removes the unwanted drop shadow

<style name="ShoppingList.BottomSheetDialog" parent="Widget.MaterialComponents.BottomSheet.Modal">
    <item name="backgroundTint">@color/....</item>
    <item name="android:elevation">0dp</item>
    <item name="elevation">0dp</item>
</style>

Thank you 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - BottomSheetDialog with transparent background
This is a version of DialogFragment that shows a bottom sheet using BottomSheetDialog instead of a floating dialog. This means there should be...
Read more >
Migrating to Material Components for Android
Let's understand these issues by going through some common migration scenarios. Text field changes. The default style for text fields has ...
Read more >
Bottomsheetdialog With Transparent Background - ADocLib
[BottomSheetDialog] android:colorBackground stopped working with version Source code: Now the BottomSheet's background is transparent, however it still With ...
Read more >
BottomSheetDialog not working [37083487] - Issue Tracker
I tried to use BottomSheetDialog introduced in Android Support Library 23.2 but it doesn't seem to work correctly. Here is what the doc...
Read more >
Make your BottomSheetDialog noncancelable - beta - Medium
Update: I wrote a standalone library for solving this issue. You can check it out at https://github.com/beta/android-lockable-bottom-sheet.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found