MaterialDatePicker not working on Android

Carina :

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.

This is the code I've tried:

MaterialDatePicker.Builder<Long> builder = MaterialDatePicker.Builder.datePicker();

MaterialDatePicker<Long> picker = builder.build();

picker.show(getSupportFragmentManager(), picker.toString());

This is how it looked like:

first image

An this is how it should've looked like:

second image

Can anybody tell me what's missing?

Thanks

Carina :

The problem was in the 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!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=138657&siteId=1