【问题标题】:How to set DayNight theme for BottomSheetDialog如何为 BottomSheetDialog 设置 DayNight 主题
【发布时间】:2020-05-19 22:18:03
【问题描述】:

我正在迁移到新的 android DayNight theme

我已将 ThemeOverlay.AppCompat.Dark(Light).ActionBar 替换为 ThemeOverlay.AppCompat.DayNight.ActionBar

ThemeOverlay.AppCompat.Dark(Light)ThemeOverlay.AppCompat.DayNight

一切看起来都很好。除了我不能对 BottomSheetDialog 做同样的事情。 BottomSheetDialog 是否存在 DayNight 主题?

【问题讨论】:

    标签: android material-design android-bottomsheetdialog theme-daynight


    【解决方案1】:

    是的,尝试使用Theme.MaterialComponents.DayNight.BottomSheetDialog。出于某种原因,Android Studio 中的代码补全不适用于这种情况。

    <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
        ...
        <item name="bottomSheetDialogTheme">@style/Theme.MaterialComponents.DayNight.BottomSheetDialog</item>
    </style>
    

    【讨论】:

      【解决方案2】:

      要使用材料组件库,您必须使用 Material Components Theme

      <style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
      

      如果你不能使用它,你应该在你的应用中使用Bridge theme

      <style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar.Bridge">
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-12-07
        • 2013-06-11
        • 2013-05-30
        • 2019-04-16
        相关资源
        最近更新 更多