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

[Dialog] Icon isn't where the specs say #4121

Closed
beatrizz opened this issue Mar 28, 2024 · 2 comments
Closed

[Dialog] Icon isn't where the specs say #4121

beatrizz opened this issue Mar 28, 2024 · 2 comments

Comments

@beatrizz
Copy link

Description: According to the specs (https://github.com/material-components/material-components-android/blob/master/docs/components/Dialog.md#anatomy-and-key-properties) when a dialog has an icon, it's at the top, above the title. However, when we set an icon in a dialog, we see the icon appear on the left of the title (in English).

image

Looking at the implementation (https://github.com/material-components/material-components-android/blob/master/lib/java/com/google/android/material/dialog/res/layout/m3_alert_dialog_title.xml) the icon is in the title layout. It's the first component inside a linear layout with horizontal orientation (https://github.com/material-components/material-components-android/blob/master/lib/java/com/google/android/material/dialog/res/values/styles.xml#L69), so the code puts it on the left (in LTR languages) of the title.

image

Expected behavior: The code and the specs match

Source code:
https://github.com/material-components/material-components-android/blob/master/lib/java/com/google/android/material/dialog/res/layout/m3_alert_dialog_title.xml
https://github.com/material-components/material-components-android/blob/master/lib/java/com/google/android/material/dialog/res/values/styles.xml#L69

Minimal sample app repro: N/A

Android API version: 30

Material Library version: 1.11.0

Device: Emulator

cc @eartle

@beatrizz beatrizz added the bug label Mar 28, 2024
@hunterstich
Copy link
Contributor

Hi @beatrizz!

Thanks so much for filing an issue.

I'm sure you're aware but you can create the center stacked dialog by either overriding your theme's materialAlertDialogTheme attribute to ThemeOverlay.MaterialComponents.MaterialAlertDialog.Centered or create one-off centered dialogs by passing in the theme overlay to MaterialAlertDialogBuilder's constructor.

I doubt we will make the theme use centered dialogs by default as it would be a large breaking visual change at this point, but I will bring it up and see what the team thinks.

@beatrizz
Copy link
Author

Thanks @hunterstich! I wasn't aware and we'll use that. We were trying to work around it with a custom title view.

From the specs, I thought the centered icon was now the default. If default dialogs stay as they are, I think it'd be useful if you could update the specs to show the default dialog (or both styles!) to avoid confusion, but it's of course up to the team. I see the attribute is documented as "Centered theme overlay" but I wasn't able to work out that it'd put the icon above the title from that description. An image or a more detailed explanation would also help there.

Thanks!

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

2 participants