Skip to content
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

[SideSheet] Modal SideSheet Width #3492

Closed
reinhardt1053 opened this issue Jul 29, 2023 · 7 comments
Closed

[SideSheet] Modal SideSheet Width #3492

reinhardt1053 opened this issue Jul 29, 2023 · 7 comments

Comments

@reinhardt1053
Copy link

Description: Currently there is no way to change the Modal SideSheet width. It works for Standard and Coplanar Side Sheets.

Expected behavior: Modal SideSheet Dialog should respect the content layout width

Android API version: 33

Material Library version: 1.8.0

Device: Pixel C

@dsn5ft
Copy link
Contributor

dsn5ft commented Jul 31, 2023

@afohrman I'm thinking this is because of the hardcoded android:layout_width in m3_side_sheet_dialog.xml:

I think we could consider moving that android:layout_width into the sideSheetModalStyle so that it can be overridden by the client. It should work because the sideSheetModalStyle is always set directly in that layout. What do you think?

@dsn5ft
Copy link
Contributor

dsn5ft commented Jul 31, 2023

Or we could come up with a different API, because setting the width from sideSheetModalStyle might not be very natural, especially if there are multiple side sheets in the same app that need different widths.

@danielrust
Copy link

@dsn5ft any traction on this?

@dsn5ft
Copy link
Contributor

dsn5ft commented Dec 13, 2023

I'll look into moving the width/height into sideSheetModalStyle so it can at least be customized somehow.

@dsn5ft dsn5ft assigned dsn5ft and unassigned afohrman Dec 13, 2023
dev210202 added a commit to PolyCoders365/Just-Turn-On-Timer that referenced this issue Jan 14, 2024
##### Modal Side Sheet width를 조절하는 방법이 1.12.0-alpha03 버전부터 지원됨에 따라 Material Library 버전 업그레이드
- [관련 이슈](material-components/material-components-android#3492)
- [문제가 해결된 커밋](material-components/material-components-android@3b278d7)

etc
- ImageButton 컴포넌트로 사용하던 아이콘 버튼을 Button 컴포넌트에 style을 입혀 Material 버튼 방식으로 변경
@akeeaggarwal
Copy link

@dev210202
App is crashing after updating to "1.12.0-alpha03" with below logs

FATAL EXCEPTION: main
Process: com.example.debug, PID: 24717
android.view.InflateException: Binary XML file line #44 in com.example.debug:layout/m3_side_sheet_dialog: Could not inflate Behavior subclass com.google.android.material.sidesheet.SideSheetBehavior
Caused by: java.lang.RuntimeException: Could not inflate Behavior subclass com.google.android.material.sidesheet.SideSheetBehavior

@afohrman
Copy link
Contributor

@akeeaggarwal thanks for reporting this! The breakage is likely because layout_width and layout_height are set in the style as of 3b278d7. This shouldn't break unless you've set a style explicitly on the modal bottom sheet that doesn't inherit from the Material3 style, and if that style doesn't set the layout_width and layout_height.

I did take a look at your code though, and it seems like you're using a modal style rather than the standard one here and here. From what I can tell, it seems like you're trying to get a standard side sheet, in which case you'd want the style="@style/Widget.Material3.SideSheet" style. You can take a look at the side sheet catalog demo to figure out which one you're looking for and for implementation tips.

@akeeaggarwal
Copy link

akeeaggarwal commented Jan 31, 2024

@afohrman Thanks for your prompt response. Can you take a look on below implementation and suggest what I am doing wrong.

This is how I am creating sidesheet by creating its object and setting the view from xml layout file -

SideSheetDialog(ctx, R.style.SideSheet)

This is my style -

<style name="SideSheet" parent="ThemeOverlay.Material3.SideSheetDialog"> shapeAppearance"= @null enforceMaterialTheme = false android:layout_width" = 400dp </style>
  1. I dont want the round corner
  2. And want the custom width with status bar

But application is crashing. Can you suggest what I am doing wrong here?

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

No branches or pull requests

5 participants