implementation 'com.google.android.material:material:1.3.0-alpha01'
use this dependency add to your build.gradle
this is on button click set this code
:
MaterialDatePicker.Builder<Pair<Long, Long>> builder = MaterialDatePicker.Builder.dateRangePicker();
CalendarConstraints.Builder constraintsBuilder = new CalendarConstraints.Builder();
builder.setTheme(R.style.CustomThemeOverlay_MaterialCalendar_Fullscreen);
builder.setCalendarConstraints(constraintsBuilder.build());
MaterialDatePicker picker = builder.build();
assert getFragmentManager() != null;
picker.show(getFragmentManager(), picker.toString());
add to into your style.xml:
<style name="CustomThemeOverlay_MaterialCalendar_Fullscreen" parent="@style/ThemeOverlay.MaterialComponents.MaterialCalendar.Fullscreen">
<item name="materialCalendarStyle">@style/Custom_MaterialCalendar.Fullscreen</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorOnSurface">@color/colorTextPrimary</item>
</style>
<style name="Custom_MaterialCalendar.Fullscreen" parent="@style/Widget.MaterialComponents.MaterialCalendar.Fullscreen">
<item name="android:windowFullscreen">false</item>
</style>
add into your whole project style Apptheme this :
<item name="materialCalendarStyle">@style/Widget.MaterialComponents.MaterialCalendar</item>
<item name="materialCalendarFullscreenTheme">@style/ThemeOverlay.MaterialComponents.MaterialCalendar.Fullscreen</item>
<item name="materialCalendarTheme">@style/ThemeOverlay.MaterialComponents.MaterialCalendar</item>