【问题标题】:ScrimBackground from Theme.MaterialComponents is not Working来自 Theme.MaterialComponents 的 ScrimBackground 不起作用
【发布时间】:2018-12-01 15:55:59
【问题描述】:

我正在尝试更改您打开对话框时显示的 scrimBackground。而且我知道在新的 MaterialComponents-Theme 中是这种情况的一个属性(scrimBackground)。但它目前不适合我。

在 material.io 网站上,背景也被描述为 scrimBackground,看起来它可以从主题中自定义。有谁知道我做错了什么?

https://material.io/design/components/dialogs.html#theming

<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

    <item name="scrimBackground">@android:color/holo_blue_light</item>

    <item name="dialogTheme">@drawable/window_scrim</item>
    <item name="android:dialogTheme">@style/DialogTheme</item>
    <item name="alertDialogTheme">@style/AlertDialogTheme</item>
    <item name="android:alertDialogTheme">@style/AlertDialogTheme</item>
</style>

<style name="DialogTheme" parent="Theme.MaterialComponents.Dialog">
    <item name="scrimBackground">@drawable/window_scrim</item>
</style>

<style name="AlertDialogTheme" parent="Theme.MaterialComponents.Dialog.Alert">
    <item name="scrimBackground">@drawable/window_scrim</item>
</style>

【问题讨论】:

    标签: android background android-alertdialog material-components-android material-theme


    【解决方案1】:

    Material code 似乎没有使用此属性,即使它已定义。 This issue 跟踪这个问题。同时,您可以使用 Changing default Android fade/scrim color when calling a Dialog 中的建议在没有 Material Theme 的情况下更改此设置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-22
      • 2011-03-23
      • 2015-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-24
      相关资源
      最近更新 更多