-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Disable maxWidth attribute in the bottom sheet #6067
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you able to file an issue at https://github.com/material-components/material-components-android about there not being a good way to remove the max width (as suggested in the Material Guidelines)? It doesn't feel like something we should have to hack around.
@@ -103,6 +103,7 @@ | |||
android:layout_height="match_parent" | |||
android:background="?colorSurface" | |||
app:behavior_hideable="true" | |||
android:maxWidth="10000dp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we do this programmatically and use Integer.MAX_VALUE
instead? It looks like that's what Android does internally.
I'd also be keen to make it more explicit what's going on here. We already have our own implementation of BottomSheetBehavior
, so we could add a method like setMaxWidth(width: Int?)
that just "disables" the max width on the underlying (actual) BottomSheetBehavior
(by setting the max width to the MAX_VALUE
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh it looks like android:maxWidth="@null"
disables it correctly so we don't to set that attribute with any big number like 10000
or Integer.MAX_VALUE
.
When it comes to doing that programmatically... I've tried it and it didn't work but either way, I think doing that in XML (the layout file) is better.
f66134b
to
97fb747
Compare
So much margin is added by default see examples from https://github.com/material-components/material-components-android/blob/master/docs/components/BottomSheet.md |
It's not a great user experience! It's worth considering changing the default. Google Maps has a nice adjustment that makes viewing and interacting easier. I think we could go ahead with the default for now and add this as a separate issue, which we can prioritize later. What do you think @grzesiek2010 @seadowg? |
Sounds good. |
Tested with Success! Verified on devices with Androids: 10, 14 Verified cases:
The top margin issue was filed separately |
Tested with Success! Verified on device with Android 11 |
Closes #6066
Why is this the best possible solution? Were any other approaches considered?
By default the max width of the bottom sheet was 640px. I think there is no way to disable that attribute other than setting its value to big enough to make the sheet full-width.
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Please just make sure that the bottom sheet is full-width.
Do we need any specific form for testing your changes? If so, please attach one.
No.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
No.
Before submitting this PR, please make sure you have:
./gradlew connectedAndroidTest
(or./gradlew testLab
) and confirmed all checks still pass