Skip to content

[BottomSheetDialog] Rounded corners in expanded state #1278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dostalleos opened this issue May 6, 2020 · 14 comments
Closed

[BottomSheetDialog] Rounded corners in expanded state #1278

dostalleos opened this issue May 6, 2020 · 14 comments
Labels

Comments

@dostalleos
Copy link

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

@wcshi
Copy link
Contributor

wcshi commented May 6, 2020

This sounds related to something @melaniegoetz is working on internally/

@jimmy-tap
Copy link

@wcshi @melaniegoetz Please provide us with expected date for solving this issue

@TonnyL
Copy link

TonnyL commented Jul 13, 2020

1.3.0-alpha01 still has this issue 🙁.

@gabrielemariotti
Copy link
Contributor

gabrielemariotti commented Aug 1, 2020

It seems to be an expected behavour.

Check this comment in PR: #437

Bad news: Our design team is strongly opinionated that rounded corners indicate scrollable content while flat corners indicate that there is no additional content. As such, they do no want us to add this change with fitToContents.

Also in the design doc there is indication to use flat corners when the bottomsheet is expanded..

Schermata 2020-08-01 alle 23 27 33

Good news: You should be able to fix this for your case by setting up a callback and overriding the shapeAppearance in the expanded state.

You can find in the PR a solution or you can check this question on SO:
https://stackoverflow.com/questions/43852562/round-corner-for-bottomsheetdialogfragment/57627229#57627229

@Fishfield
Copy link

I just stumbled upon another solution to keep the rounded corners. If you just set cornerSize, the rounded corners stay as they are when the bottom sheet is expanded. I hope this helps some of you in order to avoid those hacky workarounds

<style name="ShapeAppearance.App.LargeComponent" parent="">
	<item name="cornerFamily">rounded</item>
	<item name="cornerSize">@dimen/corner_radius_s</item>
</style>

@thevoiceless
Copy link

@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.

@lsuski
Copy link

lsuski commented 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>

@Gidde-Abhishek
Copy link

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>

This worked for me! 8/2021

@drchen
Copy link
Contributor

drchen commented Oct 1, 2021

I'll close the issue since it's WAI according to our designers' opinion and there are solutions for clients to override the behavior. Thank you all for your feedbacks!

@devs-gireeb
Copy link

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>

Your solution worked, you saved my day!

@wixeless
Copy link

Try this

class MyBottomSheer: BottomSheetDialogFragment() {

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        disableShapeAnimation()
    }

    @SuppressLint("RestrictedApi", "VisibleForTests")
    private fun disableShapeAnimation() {
        try {
            val dlg = dialog as BottomSheetDialog
            dlg.behavior.disableShapeAnimations()
        } catch (ex: Exception) {
            Log.e("BaseBottomSheet", "disableShapeAnimation Exception:", ex)
        }
    }
}

@drchen
Copy link
Contributor

drchen commented Sep 16, 2022

FYI since 1.8 rounded corners become a standard design with M3 styles, no matter it's collapsed or expanded. : )

jonnyandrew added a commit to element-hq/element-android that referenced this issue Oct 26, 2022
jonnyandrew added a commit to element-hq/element-android that referenced this issue Oct 26, 2022
jmartinesp pushed a commit to element-hq/element-android that referenced this issue Oct 26, 2022
* Add new attachments selection dialog

* Add rounded corners to bottom sheet dialog.

Note these are currently only visible in the collapsed state.
- [Google issue](https://issuetracker.google.com/issues/144859239)
- [Rejected PR](material-components/material-components-android#437)
- [Github issue](material-components/material-components-android#1278)

* Add changelog entry

* Remove redundant call to superclass click listener

* Refactor to use view visibility helper

* Change redundant sealed class to interface

* Remove unused string

* Revert "Add rounded corners to bottom sheet dialog."

This reverts commit 17c43c9.

* Remove redundant view group

* Remove redundant `this`

* Update rich text editor to latest

* Update rich text editor version

* Allow toggling rich text in the new editor

* Persist the text formatting setting

* Add changelog entry
jmartinesp pushed a commit to element-hq/element-android that referenced this issue Nov 2, 2022
* Add new attachments selection dialog

* Add rounded corners to bottom sheet dialog.

Note these are currently only visible in the collapsed state.
- [Google issue](https://issuetracker.google.com/issues/144859239)
- [Rejected PR](material-components/material-components-android#437)
- [Github issue](material-components/material-components-android#1278)

* Add changelog entry

* Remove redundant call to superclass click listener

* Refactor to use view visibility helper

* Change redundant sealed class to interface

* Remove unused string

* Revert "Add rounded corners to bottom sheet dialog."

This reverts commit 17c43c9.

* Remove redundant view group

* Remove redundant `this`

* Update rich text editor to latest

* Update rich text editor version

* Allow toggling rich text in the new editor

* Persist the text formatting setting

* Add changelog entry
@oOJohn6Oo
Copy link

For those who do not want to use M3, just upgrade to latest version and add <item name="shouldRemoveExpandedCorners">false</item> to your bottomSheetStyle theme.

@Zee604
Copy link

Zee604 commented Oct 18, 2023

pougf 👿

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests