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] Rounded corners in expanded state

See original GitHub issue

Description: BottomSheetDialog has rounded corers only if it’s not expanded. Corners are rounded as it’s specified in the ShapeAppearance during swipe or in collapsed state. Once BottomSheetDialog becomes expanded, rounded corners are animated to sharp corners.

Expected behavior: Rounded corners should not change in expanded state if expanded state is not full screen. It would be great to have ability to disable this behavior at least.

Source code:

<style name="ThemeOverlay.App.BottomSheetDialog"parent="ThemeOverlay.MaterialComponents.Dialog">
	<item name="android:windowIsFloating">false</item>
	<item name="android:windowBackground">@android:color/transparent</item>
	<item name="android:windowAnimationStyle">@style/Animation.MyTheme.BottomSheet.Modal</item>
	<item name="android:statusBarColor">@android:color/transparent</item>
	<item name="bottomSheetStyle">@style/Widget.App.BottomSheet.Modal</item>
	<item name="android:navigationBarColor">?colorSurface</item>
	<item name="android:navigationBarDividerColor" tools:ignore="NewApi">@android:color/transparent</item>
	<item name="android:windowLightStatusBar" tools:ignore="NewApi">false</item>
</style>

<style name="Widget.App.BottomSheet.Modal" parent="Widget.MaterialComponents.BottomSheet.Modal">
	<item name="shapeAppearanceOverlay">@style/ShapeAppearance.App.BottomSheet</item>
</style>

<style name="ShapeAppearance.App.BottomSheet" parent="ShapeAppearance.MaterialComponents.LargeComponent">
	<item name="cornerFamily">rounded</item>
	<item name="cornerSizeTopLeft">16dp</item>
	<item name="cornerSizeTopRight">16dp</item>
	<item name="cornerSizeBottomLeft">0dp</item>
	<item name="cornerSizeBottomRight">0dp</item>
</style>

Android API version: 29

Material Library version: 1.2.0-alpha06

Device: Pixel 3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:32
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

49reactions
lsuskicommented, May 20, 2021

You can try this:

<style name="BottomSheetDialog" parent="@style/ThemeOverlay.MaterialComponents.BottomSheetDialog">
    <item name="bottomSheetStyle">@style/BottomSheet</item>
    <item name="android:colorBackground">@color/white</item>
</style>
<style name="BottomSheet" parent="Widget.MaterialComponents.BottomSheet.Modal">
    <item name="backgroundTint">@android:color/transparent</item>
</style>

in bottom sheet layout

android:background="@drawable/rounded_top_corners_background"

drawable/rounded_top_corners_background :


<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
   <corners
          android:topLeftRadius="24dp"
          android:topRightRadius="24dp" />
   <solid android:color="?android:attr/colorBackground" />
</shape>

in activity/application theme

<item name="bottomSheetDialogTheme">@style/BottomSheetDialog</item>
13reactions
thevoicelesscommented, Oct 5, 2020

@Fishfield Can you share a more complete example? I’ve tried setting shapeAppearance and shapeAppearanceOverlay and neither seems to apply when the sheet is expanded like you said.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Round corner for BottomSheetDialogFragment - Stack Overflow
This will change all the BottomSheetDialogs of your app. ... In the expanded state the BottomSheet has flat corners .
Read more >
Customizing your bottom sheet's corners - Bryan Herbst
Here's a guide to getting your bottom sheets shaped properly! Bottom sheet with cut corner Bottom sheet with rounded corners.
Read more >
Bottom sheet dialog with Rounded corners ... - YouTube
Hello Dosto. In this tutorial, we will see how to create a bottom sheet dialog in android studio.and we will implement Model bottomsheet...
Read more >
Show rounded corners for BottomSheetDialogFragment
“Show rounded corners for BottomSheetDialogFragment” is published by Travis Kim. ... Create round shape of the BottomSheetDialog as shape_rounded_dialog.xml ...
Read more >
BottomSheetBehavior - Android Developers
Gets the friction coefficient to hide the bottom sheet, or set it to the next closest expanded state. int, getMaxHeight().
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