如何在键盘模式中更改 "MaterialDatePicker" 的颜色,并且可以在 Android 中隐藏该模式?

How to change the color of the "MaterialDatePicker" in keyboard Mode & also it is possible to hide that mode in Android?

我已经更改了下面 link 的 MaterialDatePicker 的默认主题,但是我无法在 键盘模式下更改颜色 日期选择 & 也可以隐藏那个模式?

关于 MaterialDatePicker.INPUT_MODE_TEXT 中的 TextInputLayout

它是一个标准 TextInputLayout,它继承自您应用主题中定义的 textInputStyle 属性。在默认的 Material Components 主题中,它由 Widget.MaterialComponents.TextInputLayout.FilledBox 定义并且基于:

  • 背景颜色(boxBackgroundColor属性):colorOnSurface
  • 下划线颜色(boxStrokeColor属性)colorPrimary(重点)和colorOnSurface(其他状态)

1.3.0-alpha03开始,您可以使用主题:

   setTheme(R.style.ThemeOverlay_App_MaterialCalendar)

与:

<style name="ThemeOverlay.App.MaterialCalendar" parent="@style/ThemeOverlay.MaterialComponents.MaterialCalendar">
    <item name="textInputStyle">@style/Widget.App.TextInputLayout</item>
</style>

<style name="Widget.App.TextInputLayout" parent="Widget.MaterialComponents.TextInputLayout.FilledBox">
    <item name="boxBackgroundColor">@color/....</item>
</style>

1.3.0-alpha03 之前,您只能使用应用中的 textInputStyle 更改应用中 all TextInputLayout 的默认样式主题。

 <style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
   .... 
   <item name="textInputStyle">@style/My_FilledBox</item>
 </style>

 <style name="My_FilledBox" parent="@style/Widget.MaterialComponents.TextInputLayout.FilledBox">
     ...
  </style>


隐藏 header 中的切换 的方法不存在,但有一个解决方法(它可以在未来的版本中停止工作):

builder.setTheme(R.style.MyMaterialCalendarTheme);

与:

 <style name="MyMaterialCalendarTheme" parent="ThemeOverlay.MaterialComponents.MaterialCalendar">
    <!-- HeaderToggleButton -->
    <item name="materialCalendarHeaderToggleButton">@style/HeaderToggleButton1</item>
 </style>

  <style name="HeaderToggleButton1" parent="@style/Widget.MaterialComponents.MaterialCalendar.HeaderToggleButton">
    <item name="android:visibility">gone</item>
  </style>