diff --git a/lib/java/com/google/android/material/color/DynamicColors.java b/lib/java/com/google/android/material/color/DynamicColors.java index d4767a975b2..e271566f8d9 100644 --- a/lib/java/com/google/android/material/color/DynamicColors.java +++ b/lib/java/com/google/android/material/color/DynamicColors.java @@ -315,7 +315,8 @@ private static void applyDynamicColorThemeOverlay(Activity activity, @StyleRes i private static Theme getWindowDecorViewTheme(@NonNull Activity activity) { Window window = activity.getWindow(); if (window != null) { - View decorView = window.getDecorView(); + // Use peekDecorView() instead of getDecorView() to avoid locking the Window. + View decorView = window.peekDecorView(); if (decorView != null) { Context context = decorView.getContext(); if (context != null) {