MaterialDatePicker在Android上不起作用 [英] MaterialDatePicker not working on Android

查看:134
本文介绍了MaterialDatePicker在Android上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将项目的日期选择器更改为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的默认颜色是白色",并且Material Date Picker样式使用该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天全站免登陆