如何在键盘模式下更改“ MaterialDatePicker”的颜色,还可以在Android中隐藏该模式?

问题描述 投票:0回答:1

我已经更改了下面链接的MaterialDatePicker的默认主题,但是我无法在日期选择的键盘模式中更改颜色,还可以隐藏该模式吗?

How to change Theme of "MaterialDatePicker" in Android? enter image description here

android material-design android-datepicker material-components-android material-components
1个回答
1
投票

这不是一个很好的答案。

当前(1.2.0-beta01)那里不是仅自定义SingleDateSelector中的视图的方法。它基于this layout,不会显示任何样式。

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

  • 背景色(boxBackgroundColor属性:colorOnSurface] >>
  • 下划线颜色(boxStrokeColor属性)colorPrimary(聚焦)和colorOnSurface(其他状态)
  • 您只能使用应用程序主题中的TextInputLayout来更改应用程序中all

textInputStyle的默认样式。
 <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>

不见了


在标题中没有隐藏切换

的方法,但是有一种解决方法(在以后的版本中它可能会停止工作:]
builder.setTheme(R.style.MyMaterialCalendarTheme);

with:

 <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>

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.