-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
[bottomsheet] do not remove corners when bottomsheet is not fully expanded #437
Conversation
Please create a GitHub issue for tracking this - it will help us prioritize reviewing this. Thanks! |
I have bad news and good news. 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. 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. |
Please, which callback do you mean? |
I believe BottomSheetBehavior#addBottomSheetCallback. |
I just realized this method wasn't on github until just now. Sorry about that. |
This is such an arbitrary decision. The API should default to the designers' opinions, but not lock them in. Design is fleeting, and these types of restrictions don't stop customization, they just make it more difficult. The whole concept of "it can't be customized because our designers feel strongly about it" is short-sighted, at best. Some other things Google's Android designers have felt strongly about but eventually changed their minds on:
That's just to name a few. Please consider adding a proper configuration option to control this behavior. "Designers said no" is simply not a valid reason for omission. |
@ldjcmu can you give an example of how that workaround would work? Especially considering only one callback can be set per behavior, it's fairly inconvenient to have to use that for every sheet if this is something we need to work around app-wide. |
I agree with @iPaulPro , please add this as an option so that we don't have to write workaround like now. |
Would like to bump this issue. Another point here - can these so called opinions be added into official Material Guideline, so there will be less misunderstandings? Because this repo already has some issues with some feedback from design team. |
As an example. Note that you still need to set the shapeAppearnceOverlay in your bottomSheetStyle.
|
@ldjcmu |
I totally agree with @iPaulPro. Just to improve the code posted above by @alex-signal:
with:
|
Notwithstanding the fact that this excuse is clearly ridiculous, if we actually spend a moment to think about what they said, the whole thing becomes even more ridiculous. Rounded corners indicate scrollable content? What? If my bottom sheet has rounded corners, and then the user fully expands the sheet until it stops, they very clearly understand that the sheet is expanded. Keeping rounded corners on that wouldn't affect that. I've used dozens of apps that have permanent rounded corners on the bottom sheet, not been a problem, and those designers don't think so either. So not only is your excuse quite bizarre, but the justification is equally bizarre. |
I'm surprised! 😲 |
Actually, there's an option for us to disable animation by calling + @SuppressLint("RestrictedApi")
override fun onCreateDialog(savedInstanceState: Bundle?): BottomSheetDialog {
val bottomSheetDialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog
+ bottomSheetDialog.behavior.disableShapeAnimations()
return bottomSheetDialog
} However, the API is still restricted, but you can suppress it by putting Exampleimport android.annotation.SuppressLint
import android.os.Bundle
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
abstract class BottomSheetFragment : BottomSheetDialogFragment() {
@SuppressLint("RestrictedApi")
override fun onCreateDialog(savedInstanceState: Bundle?): BottomSheetDialog {
val bottomSheetDialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog
bottomSheetDialog.behavior.disableShapeAnimations()
return bottomSheetDialog
}
} |
Have not tried yet, but I'm afraid using |
I just stumbled upon another solution to keep the rounded corners. If you just set
|
Screenshot of Youtube app on Android : Google's design team seems to have very fickle design opinions 🤔 @ldjcmu Please reconsider this PR or at least provide us a stable and reliable way to achieve what so many developers here want. We would be very grateful. |
Used @seanghay 's workaround and it seems to work properly. Really hope this just becomes a public API. My designer's do not like being boxed in by the opinion's of Material Design, and this is the path of least resistance. |
Unfortunately this does not work for me. But custom drawable seems to work fine. Maybe it's worth voting for corresponding issue on Google Issue Tracker. |
If you need I want to share the workaround I found. Looking at the code of /** True if Behavior has a non-null value for the @shapeAppearance attribute */
private boolean shapeThemingEnabled; Turns out if shape theming is disabled, // Only set MaterialShapeDrawable as background if shapeTheming is enabled, otherwise will
// default to android:background declared in styles or layout.
if (shapeThemingEnabled && materialShapeDrawable != null) {
ViewCompat.setBackground(child, materialShapeDrawable);
} Defaulting to We can disable material theming by creating a separate style and setting <style name="Theme.YourApp.NoShapeBottomSheetDialog" parent="Theme.MaterialComponents.BottomSheetDialog">
<item name="bottomSheetStyle">@style/Theme.YourApp.NoShapeButtonSheet</item>
</style>
<style name="Theme.YourApp.NoShapeButtonSheet" parent="Widget.MaterialComponents.BottomSheet.Modal">
<item name="shapeAppearance">@null</item>
<item name="shapeAppearanceOverlay">@null</item>
</style> Extend
The bottom sheet is now naked, without any background at all. So we can add any background we want, no animation will be triggered anymore. |
Nice solution @rickchristie thanks a lot ! |
I'm agree with people above, just add this feature to public API and let us think out of box exclude your Material Design team. |
+1 |
Try this
} |
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)
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 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
* 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
Starting from 1.8.0-alpha2 shouldRemoveExpandedCorners style attribute is available to override default behaviour. |
Currently, when bottomsheet is in expanded state and its content is wrapped (fitToContents) then the corners are animated to 0dp. This leads to quite unwanted behavior. This PR fixes this to check fitToContents variable.
Screenshots attached from catalog app. (large shape corner size in settings required):
Before:
After: