MaterialDatePicker 不适用于 Android [英] MaterialDatePicker not working on Android

查看:42
本文介绍了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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆