如何实现 Google 的 Android 12 个应用程序小部件背景?

How to achieve Google's Android 12 app widgets backgrounds?

Android 12 使用系统默认主题 @android:style/Theme.DeviceDefault.DayNight.

附带了新的应用小部件功能 “设备主题”

the documentation 中看到如下所示的屏幕截图,我期待看到更多的主题颜色可以在我自己的小部件中使用:

与上面的屏幕截图和 Google 的应用程序小部件(如天气和 Gmail 的小部件)相比,我几乎无法测量拾取的任何颜色。

我也尝试了 Material Design 3 的方法,通过 Theme.Material3.DynamicColors.DayNight 实现了同样的结果。下面的屏幕截图显示了 the Material design example app widget 与 Google 的天气小部件 - 运行 在 Android 12 Pixel 5 设备上。

Google 的应用小部件从设备主题中获取更多颜色的不同之处是什么?

我听说了 system_accent1_* colours and the blog post https://medium.com/@xch3dx/using-material-you-in-your-app-15ec982eecb4

使用 <item name="android:backgroundTint">@android:color/system_accent1_50</item> 我终于得到了与 Google 的小部件相同的背景颜色。