MaterialDatePicker 不适用于 Android

编程入门 行业动态 更新时间:2024-10-22 05:07:24
本文介绍了MaterialDatePicker 不适用于 Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想将我的项目的日期选择器更改为 Material Components for Android 提供的日期选择器,但它不起作用.

I want to change the date picker of my project to the date picker provided by the Material Components for Android, but it is not working.

这是我试过的代码:

MaterialDatePicker.Builder<Long> builder = MaterialDatePicker.Builder.datePicker(); MaterialDatePicker<Long> picker = builder.build(); picker.show(getSupportFragmentManager(), picker.toString());

这是它的样子:

它应该是这样的:

谁能告诉我遗漏了什么?

Can anybody tell me what's missing?

谢谢

推荐答案

问题出在 colorPrimary.

The problem was in the colorPrimary.

我的项目 colorPrimary 的默认颜色是白色",材质日期选择器样式使用该 colorPrimary 为按钮的背景和文本着色.由于标题文本的颜色也是白色,所以看起来什么都没有.

The default color of my project to colorPrimary was "white" and the Material Date Picker style uses that colorPrimary to color the background and the text of the buttons. Since the color of the header text was also white, it appear that there was nothing there when there was everything.

我通过将样式文件导入我的项目并对我的项目中的样式进行一些调整来解决它.

I solved it by importing the styles file to my project and making some adjustments to the styles in my project.

感谢大家的回答,他们都帮助找到了问题!

Thank you all for your answers, all of them helped in finding the problem!

更多推荐

MaterialDatePicker 不适用于 Android

本文发布于:2023-11-23 14:04:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1621703.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不适用于   MaterialDatePicker   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!