material-components / material-components-android

Modular and customizable Material Design UI components for Android
Apache License 2.0
16.35k stars 3.06k forks source link

[MaterialAlertDialogBuilder] Wrong Dialog bounds after orientation change #2408

Closed thinhlai closed 3 years ago

thinhlai commented 3 years ago

Description: Dialog bounds is not correct after orientation change without activity recreation (activity has configChanges=orientation attribute)

screenshot-1633432645336 screenshot-1633429718933

How to reproduce it

1 . Start app at portrait -> then click button to show alert dialog.

  1. Then rotate device to landscape
  2. Press physical home button to exit app
  3. Then rotate device again to portrait
  4. Press physical task manager button
  5. Select and resume app on task manager
  6. The issue appears

Expected behavior: Dialog bounds is showed correctly after orientation change

Source code: TestDialog.zip

Android API version: Any Android API versions

Material Library version: 1.5.0-alpha04

Device: Any devices

drchen commented 3 years ago

Hi, I think this is a bug of Android dialog implementation and the recommended solution will be using DialogFragment instead. : )

I checked with our demo app and replace the implementation with AppCompatDialogFragment did fix the issue. : )